From 2c8056acdf267c8e36fdfb6a3af286972d27f655 Mon Sep 17 00:00:00 2001 From: Dario Lombardo Date: Mon, 13 Jun 2016 20:02:46 +0200 Subject: Qt: quit the UI if WIRESHARK_QUIT_AFTER_CAPTURE is set (offline mode too). This change is useful to use the offline mode in tests (like fuzzing) that require the software to quit after the processing of a sample. Change-Id: I311c642edecf4012dc518c2bf8bca66c97aa1b02 Reviewed-on: https://code.wireshark.org/review/16038 Petri-Dish: Alexis La Goutte Tested-by: Petri Dish Buildbot Reviewed-by: Anders Broman --- ui/qt/main_window.cpp | 5 +++++ ui/qt/main_window_slots.cpp | 15 +++++++++++---- 2 files changed, 16 insertions(+), 4 deletions(-) (limited to 'ui') diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp index 4e2e637d91..137aae78a8 100644 --- a/ui/qt/main_window.cpp +++ b/ui/qt/main_window.cpp @@ -246,6 +246,11 @@ simple_message_box(ESD_TYPE_E type, gboolean *notagain, void vsimple_error_message_box(const char *msg_format, va_list ap) { + // We want to quit after reading the capture file, hence + // we don't actually open the error dialog. + if (global_capture_opts.quit_after_cap) + exit(0); + SimpleDialog sd(gbl_cur_main_window_, ESD_TYPE_ERROR, ESD_BTN_OK, msg_format, ap); sd.exec(); } diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp index 1bd54ce9d1..38a441b1a7 100644 --- a/ui/qt/main_window_slots.cpp +++ b/ui/qt/main_window_slots.cpp @@ -178,6 +178,7 @@ bool MainWindow::openCaptureFile(QString cf_path, QString read_filter, unsigned gchar *err_msg; int err; gboolean name_param; + gboolean ret = true; // was a file name given as function parameter? name_param = !cf_path.isEmpty(); @@ -190,13 +191,15 @@ bool MainWindow::openCaptureFile(QString cf_path, QString read_filter, unsigned if (open_dlg.open(file_name, type)) { cf_path = file_name; } else { - return false; + ret = false; + goto finish; } } QString before_what(tr(" before opening another file")); if (!testCaptureFileClose(before_what)) { - return false; + ret = false; + goto finish; } if (dfilter_compile(read_filter.toUtf8().constData(), &rfcode, &err_msg)) { @@ -249,7 +252,8 @@ bool MainWindow::openCaptureFile(QString cf_path, QString read_filter, unsigned string and return (without changing the last containing directory). */ capture_file_.setCapFile(NULL); - return false; + ret = false; + goto finish; } break; } @@ -258,7 +262,10 @@ bool MainWindow::openCaptureFile(QString cf_path, QString read_filter, unsigned main_ui_->statusBar->showExpert(); - return true; +finish: + if (global_capture_opts.quit_after_cap) + exit(0); + return ret; } void MainWindow::filterPackets(QString new_filter, bool force) -- cgit v1.2.3