Qt: Stop tapping when the I/O Graph dialog closes.

Add a setCaptureStopFlag function to ProgressBar. Add a stopTapping
function and setCaptureStopFlag signal to CaptureFile. Use the new
plubming to stop tapping when the IO Graph dialog closes.

Bug: 10116
Change-Id: Ic46814eed18933f511d9d1ff37e2e7918741f353
Reviewed-on: https://code.wireshark.org/review/8480
Petri-Dish: Gerald Combs <gerald@wireshark.org>
Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org>
Reviewed-by: Gerald Combs <gerald@wireshark.org>
This commit is contained in:
Gerald Combs 2015-05-15 13:36:04 -07:00
parent a1eb0aaeb3
commit a04a894731
8 changed files with 37 additions and 1 deletions

View File

@ -41,6 +41,8 @@ capture_file cfile;
// - Add getters and (if needed) setters:
// - Full filename
// - Capture state (stopped, prepared, running).
// - Call common_create_progress_dlg. This would let us manage the stop
// flag here as well as emit progress signals.
QString CaptureFile::no_capture_file_ = QObject::tr("[no capture file]");
@ -83,6 +85,11 @@ void CaptureFile::retapPackets()
}
}
void CaptureFile::stopTapping()
{
emit setCaptureStopFlag(true);
}
capture_file *CaptureFile::globalCapFile()
{
return &cfile;

View File

@ -65,6 +65,11 @@ public:
*/
void retapPackets();
/** Cancel any tapping that might be in progress.
*/
void stopTapping();
// XXX This shouldn't be needed.
static capture_file *globalCapFile();
@ -87,6 +92,8 @@ signals:
void captureCaptureStopping(capture_session *cap_session);
void captureCaptureFailed(capture_session *cap_session);
void setCaptureStopFlag(bool);
public slots:
private:

View File

@ -314,11 +314,13 @@ IOGraphDialog::IOGraphDialog(QWidget &parent, CaptureFile &cf) :
IOGraphDialog::~IOGraphDialog()
{
cap_file_.stopTapping();
for (int i = 0; i < ui->graphTreeWidget->topLevelItemCount(); i++) {
IOGraph *iog = qvariant_cast<IOGraph *>(ui->graphTreeWidget->topLevelItem(i)->data(name_col_, Qt::UserRole));
delete iog;
}
delete ui;
ui = NULL;
}
void IOGraphDialog::addGraph(bool checked, QString name, QString dfilter, int color_idx, IOGraph::PlotStyles style, io_graph_item_unit_t value_units, QString yfield, int moving_average)
@ -953,7 +955,8 @@ void IOGraphDialog::updateStatistics()
if (need_retap_ && !file_closed_) {
need_retap_ = false;
cap_file_.retapPackets();
ui->ioPlot->setFocus();
// The user might have closed the window while tapping, which means
// we might no longer exist.
} else {
if (need_recalc_ && !file_closed_) {
need_recalc_ = false;

View File

@ -321,6 +321,9 @@ MainWindow::MainWindow(QWidget *parent) :
connect(&capture_file_, SIGNAL(captureFileClosed()),
this, SLOT(captureFileClosed()));
connect(&capture_file_, SIGNAL(setCaptureStopFlag(bool)),
this, SLOT(setCaptureStopFlag(bool)));
connect(&capture_file_, SIGNAL(captureFileReadStarted()),
wsApp, SLOT(captureFileReadStarted()));
connect(&capture_file_, SIGNAL(captureFileReadFinished()),

View File

@ -193,6 +193,7 @@ public slots:
// in main_window_slots.cpp
void openCaptureFile(QString& cf_path = *new QString(), QString& display_filter = *new QString(), unsigned int type = WTAP_TYPE_AUTO);
void filterPackets(QString& new_filter = *new QString(), bool force = false);
void setCaptureStopFlag(bool stop_flag = true);
void updateForUnsavedChanges();
void layoutPanes();
void applyRecentPaneGeometry();

View File

@ -255,6 +255,15 @@ void MainWindow::filterPackets(QString& new_filter, bool force)
}
}
// XXX We should probably call common_create_progress_dlg in CaptureFile and
// have it handle emitting progress signals and the stop flag.
void MainWindow::setCaptureStopFlag(bool stop_flag)
{
ProgressBar *progress_bar = main_ui_->statusBar->findChild<ProgressBar *>();
if (progress_bar) progress_bar->setStopFlag(stop_flag);
}
// A new layout should be applied when it differs from the old layout AND
// at the following times:
// - At startup

View File

@ -184,6 +184,11 @@ progdlg_t * ProgressBar::show(bool animate, bool terminate_is_stop, gboolean *st
return &progress_dialog_;
}
void ProgressBar::setStopFlag(bool stop_flag)
{
if (stop_flag_) *stop_flag_ = stop_flag;
}
#ifdef QWINTASKBARPROGRESS_H
void ProgressBar::hide()
{

View File

@ -51,6 +51,7 @@ public:
#ifdef QWINTASKBARPROGRESS_H
void hide();
#endif
void setStopFlag(bool stop_flag);
private:
progdlg_t progress_dialog_;