aboutsummaryrefslogtreecommitdiffstats
path: root/ui/qt/main_window_slots.cpp
diff options
context:
space:
mode:
authorStig Bjørlykke <stig@bjorlykke.org>2021-06-07 14:22:20 +0200
committerWireshark GitLab Utility <gerald+gitlab-utility@wireshark.org>2021-06-07 13:52:59 +0000
commit44a615e854e1e8281cf7d88dcb435fbbaba9e2ab (patch)
treea23a37b5dd71359a1bdf71619f493bc2986379bb /ui/qt/main_window_slots.cpp
parent8c79fa5e1b9890668444e374b6df9e63b80a133c (diff)
Qt: Give a directory to wsApp->setLastOpenDir()
Use wsApp->setLastOpenDirFromFilename() to convert a filename to a directory name before calling wsApp->setLastOpenDir(). This will ensure to always store a directory instead of a filename in the recent gui.fileopen_remembered_dir.
Diffstat (limited to 'ui/qt/main_window_slots.cpp')
-rw-r--r--ui/qt/main_window_slots.cpp13
1 files changed, 4 insertions, 9 deletions
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp
index 1c6d945808..947914411c 100644
--- a/ui/qt/main_window_slots.cpp
+++ b/ui/qt/main_window_slots.cpp
@@ -275,8 +275,7 @@ bool MainWindow::openCaptureFile(QString cf_path, QString read_filter, unsigned
break;
}
- // get_dirname overwrites its path.
- wsApp->setLastOpenDir(get_dirname(cf_path.toUtf8().data()));
+ wsApp->setLastOpenDirFromFilename(cf_path);
main_ui_->statusBar->showExpert();
@@ -760,16 +759,12 @@ void MainWindow::captureFileReadStarted(const QString &action) {
}
void MainWindow::captureFileReadFinished() {
- gchar *dir_path;
-
if (!capture_file_.capFile()->is_tempfile && capture_file_.capFile()->filename) {
/* Add this filename to the list of recent files in the "Recent Files" submenu */
add_menu_recent_capture_file(capture_file_.capFile()->filename);
/* Remember folder for next Open dialog and save it in recent */
- dir_path = g_strdup(capture_file_.capFile()->filename);
- wsApp->setLastOpenDir(get_dirname(dir_path));
- g_free(dir_path);
+ wsApp->setLastOpenDirFromFilename(capture_file_.capFile()->filename);
}
/* Update the appropriate parts of the main window. */
@@ -1802,7 +1797,7 @@ void MainWindow::on_actionFileExportPacketBytes_triggered()
write_file_binary_mode(qUtf8Printable(file_name), data_p, capture_file_.capFile()->finfo_selected->length);
/* Save the directory name for future file dialogs. */
- wsApp->setLastOpenDir(file_name);
+ wsApp->setLastOpenDirFromFilename(file_name);
}
}
@@ -1861,7 +1856,7 @@ void MainWindow::on_actionFileExportTLSSessionKeys_triggered()
write_file_binary_mode(qUtf8Printable(file_name), keylist, keylist_length);
/* Save the directory name for future file dialogs. */
- wsApp->setLastOpenDir(file_name);
+ wsApp->setLastOpenDirFromFilename(file_name);
g_free(keylist);
}
}