diff options
Diffstat (limited to 'ui')
-rw-r--r-- | ui/qt/main_window.cpp | 13 | ||||
-rw-r--r-- | ui/qt/main_window.h | 3 | ||||
-rw-r--r-- | ui/qt/main_window_slots.cpp | 16 |
3 files changed, 27 insertions, 5 deletions
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp index f7777663f5..2dbcd25074 100644 --- a/ui/qt/main_window.cpp +++ b/ui/qt/main_window.cpp @@ -1592,8 +1592,14 @@ bool MainWindow::testCaptureFileClose(QString before_what, FileCloseContext cont question = tr("Do you want to stop the capture and save the captured packets%1?").arg(before_what); infotext = tr("Your captured packets will be lost if you don't save them."); } else if (capture_file_.capFile()->is_tempfile) { - question = tr("Do you want to save the captured packets%1?").arg(before_what); - infotext = tr("Your captured packets will be lost if you don't save them."); + if (context == Reload) { + // Reloading a tempfile will keep the packets, so this is not unsaved packets + question = tr("Do you want to save the changes you've made%1?").arg(before_what); + infotext = tr("Your changes will be lost if you don't save them."); + } else { + question = tr("Do you want to save the captured packets%1?").arg(before_what); + infotext = tr("Your captured packets will be lost if you don't save them."); + } } else { // No capture in progress and not a tempfile, so this is not unsaved packets gchar *display_basename = g_filename_display_basename(capture_file_.capFile()->filename); @@ -1691,7 +1697,8 @@ bool MainWindow::testCaptureFileClose(QString before_what, FileCloseContext cont captureStop(); #endif /* captureStop() will close the file if not having any packets */ - if (capture_file_.capFile()) + if (capture_file_.capFile() && context != Restart && context != Reload) + // Don't really close if Restart or Reload cf_close(capture_file_.capFile()); } diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h index 311005c8f0..20c7233f32 100644 --- a/ui/qt/main_window.h +++ b/ui/qt/main_window.h @@ -124,7 +124,8 @@ private: enum FileCloseContext { Default, Quit, - Restart + Restart, + Reload }; Ui::MainWindow *main_ui_; diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index 574c522545..56bbec4c30 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -2506,13 +2506,27 @@ void MainWindow::on_actionContextShowLinkedPacketInNewWindow_triggered() void MainWindow::on_actionViewReload_triggered() { - cf_reload(CaptureFile::globalCapFile()); + capture_file *cf = CaptureFile::globalCapFile(); + + if (cf->unsaved_changes) { + QString before_what(tr(" before reloading the file")); + if (!testCaptureFileClose(before_what, Reload)) + return; + } + + cf_reload(cf); } void MainWindow::on_actionViewReload_as_File_Format_or_Capture_triggered() { capture_file *cf = CaptureFile::globalCapFile(); + if (cf->unsaved_changes) { + QString before_what(tr(" before reloading the file")); + if (!testCaptureFileClose(before_what, Reload)) + return; + } + if (cf->open_type == WTAP_TYPE_AUTO) cf->open_type = open_info_name_to_type("MIME Files Format"); else /* TODO: This should be latest format chosen by user */ |