aboutsummaryrefslogtreecommitdiffstats
path: root/ui
diff options
context:
space:
mode:
authorMichael Mann <mmann78@netscape.net>2015-12-19 16:36:30 -0500
committerMichael Mann <mmann78@netscape.net>2015-12-21 13:26:30 +0000
commit39bdeb2706d552be51a07be30ddb2433a1f044b2 (patch)
tree2f57ac5e76e3adaf662ab3df9af0434b56395dec /ui
parente3829d723dc85387665e2843e08a30954766506e (diff)
Confirm discarding data before restarting capture.
Modify existing MainWindow::testCaptureFileClose() to handle restart scenario. Bug: 9605 Change-Id: Ie57624ca482b050745474f5e1c61343f60292a42 Reviewed-on: https://code.wireshark.org/review/12733 Petri-Dish: Michael Mann <mmann78@netscape.net> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Stig Bjørlykke <stig@bjorlykke.org> Reviewed-by: Michael Mann <mmann78@netscape.net>
Diffstat (limited to 'ui')
-rw-r--r--ui/qt/main_window.cpp37
-rw-r--r--ui/qt/main_window.h2
-rw-r--r--ui/qt/main_window_slots.cpp4
3 files changed, 30 insertions, 13 deletions
diff --git a/ui/qt/main_window.cpp b/ui/qt/main_window.cpp
index 2bdf68d40f..e1495e2985 100644
--- a/ui/qt/main_window.cpp
+++ b/ui/qt/main_window.cpp
@@ -1500,7 +1500,7 @@ void MainWindow::fileAddExtension(QString &file_name, int file_type, bool compre
}
}
-bool MainWindow::testCaptureFileClose(bool from_quit, QString before_what) {
+bool MainWindow::testCaptureFileClose(bool from_quit, QString before_what, bool restart) {
bool capture_in_progress = FALSE;
if (!capture_file_.capFile() || capture_file_.capFile()->state == FILE_CLOSED)
@@ -1571,7 +1571,11 @@ bool MainWindow::testCaptureFileClose(bool from_quit, QString before_what) {
msg_dialog.addButton(QMessageBox::Cancel);
if (capture_in_progress) {
- saveButton = msg_dialog.addButton(tr("Stop and Save"), QMessageBox::AcceptRole);
+ if (restart) {
+ saveButton = msg_dialog.addButton(tr("Save before Continue"), QMessageBox::AcceptRole);
+ } else {
+ saveButton = msg_dialog.addButton(tr("Stop and Save"), QMessageBox::AcceptRole);
+ }
} else {
saveButton = msg_dialog.addButton(QMessageBox::Save);
}
@@ -1587,8 +1591,14 @@ bool MainWindow::testCaptureFileClose(bool from_quit, QString before_what) {
}
} else {
if (capture_in_progress) {
- discardButton = msg_dialog.addButton(tr("Stop and Continue without Saving"),
- QMessageBox::DestructiveRole);
+ if (restart) {
+ discardButton = msg_dialog.addButton(tr("Continue without Saving"),
+ QMessageBox::DestructiveRole);
+ }
+ else {
+ discardButton = msg_dialog.addButton(tr("Stop and Continue without Saving"),
+ QMessageBox::DestructiveRole);
+ }
} else {
discardButton = msg_dialog.addButton(tr("Continue &without Saving"), QMessageBox::DestructiveRole);
}
@@ -1613,16 +1623,19 @@ bool MainWindow::testCaptureFileClose(bool from_quit, QString before_what) {
}
else if(msg_dialog.clickedButton() == discardButton)
{
+ if (!restart)
+ {
#ifdef HAVE_LIBPCAP
- /*
- * If there's a capture in progress; we have to stop the capture
- * and then do the close.
- */
- if (capture_in_progress)
- captureStop();
+ /*
+ * If there's a capture in progress; we have to stop the capture
+ * and then do the close.
+ */
+ if (capture_in_progress)
+ captureStop();
#endif
- /* Just close the file, discarding changes */
- cf_close(capture_file_.capFile());
+ /* Just close the file, discarding changes */
+ cf_close(capture_file_.capFile());
+ }
return true;
}
else //cancelButton or some other unspecified button
diff --git a/ui/qt/main_window.h b/ui/qt/main_window.h
index abd63e2910..c2cdd090fb 100644
--- a/ui/qt/main_window.h
+++ b/ui/qt/main_window.h
@@ -179,7 +179,7 @@ private:
void exportDissections(export_type_e export_type);
void fileAddExtension(QString &file_name, int file_type, bool compressed);
- bool testCaptureFileClose(bool from_quit = false, QString before_what = QString());
+ bool testCaptureFileClose(bool from_quit = false, QString before_what = QString(), bool restart = false);
void captureStop();
void initMainToolbarIcons();
diff --git a/ui/qt/main_window_slots.cpp b/ui/qt/main_window_slots.cpp
index cb6f8eff0f..91ce271fb9 100644
--- a/ui/qt/main_window_slots.cpp
+++ b/ui/qt/main_window_slots.cpp
@@ -3475,6 +3475,10 @@ void MainWindow::on_actionCaptureStop_triggered()
void MainWindow::on_actionCaptureRestart_triggered()
{
+ QString before_what(tr(" before restarting a new capture"));
+ if (!testCaptureFileClose(FALSE, before_what, true))
+ return;
+
/* TODO: GTK use only this: capture_restart(&cap_session_); */
captureStop();
startCapture();