# HG changeset patch # User John Donoghue # Date 1396225098 14400 # Node ID 40dce9423baa5b52919f68e494f9f812aae01064 # Parent 400f48e9e8cba9dc728c79cb6ec17fe0051f7ac9 uigetdir: return correct path name (Bug #42004) * libgui/src/dialog.cc (FileDialog::accept): When in dir mode, get the full path name from the selected file. diff -r 400f48e9e8cb -r 40dce9423baa libgui/src/dialog.cc --- a/libgui/src/dialog.cc Sun Mar 30 13:00:36 2014 -0700 +++ b/libgui/src/dialog.cc Sun Mar 30 20:18:18 2014 -0400 @@ -485,23 +485,25 @@ string_result = selectedFiles (); + if (testOption (QFileDialog::ShowDirsOnly) == true && + string_result.size () > 0) + { + path = string_result[0]; + } + else + { + path = directory ().absolutePath (); + } + // Matlab expects just the file name, whereas the file dialog gave us - // pull path names, so fix it. + // full path names, so fix it. for (int i = 0; i < string_result.size (); i++) string_result[i] = QFileInfo (string_result[i]).fileName (); - path = directory ().absolutePath (); - // if not showing only dirs, add end slash for the path component if (testOption (QFileDialog::ShowDirsOnly) == false) path = path + "/"; - else - { - // if name was provided in uigetdir, add to path - if (string_result.size() > 0) - path = path + "/" + string_result[0]; - } // convert to native slashes path = QDir::toNativeSeparators (path);