Qt: quit the UI if WIRESHARK_QUIT_AFTER_CAPTURE is set (offline mode too).
authorDario Lombardo <lomato@gmail.com>
Mon, 13 Jun 2016 18:02:46 +0000 (20:02 +0200)
committerAnders Broman <a.broman58@gmail.com>
Thu, 23 Jun 2016 07:58:29 +0000 (07:58 +0000)
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 <alexis.lagoutte@gmail.com>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Anders Broman <a.broman58@gmail.com>
ui/qt/main_window.cpp
ui/qt/main_window_slots.cpp

index 4e2e637d91534615de3237cc50b829a9e2a61c82..137aae78a8d12ce9d685b55ee1025447b4a33b9b 100644 (file)
@@ -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();
 }
index 1bd54ce9d101feeab5c10baf43b6e88fc7b1cafc..38a441b1a7fdfad1b4d48bd4a52d65597d7d91b7 100644 (file)
@@ -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)