forked from osmocom/wireshark
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:
parent
a1eb0aaeb3
commit
a04a894731
|
@ -41,6 +41,8 @@ capture_file cfile;
|
||||||
// - Add getters and (if needed) setters:
|
// - Add getters and (if needed) setters:
|
||||||
// - Full filename
|
// - Full filename
|
||||||
// - Capture state (stopped, prepared, running).
|
// - 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]");
|
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()
|
capture_file *CaptureFile::globalCapFile()
|
||||||
{
|
{
|
||||||
return &cfile;
|
return &cfile;
|
||||||
|
|
|
@ -65,6 +65,11 @@ public:
|
||||||
*/
|
*/
|
||||||
void retapPackets();
|
void retapPackets();
|
||||||
|
|
||||||
|
/** Cancel any tapping that might be in progress.
|
||||||
|
*/
|
||||||
|
void stopTapping();
|
||||||
|
|
||||||
|
|
||||||
// XXX This shouldn't be needed.
|
// XXX This shouldn't be needed.
|
||||||
static capture_file *globalCapFile();
|
static capture_file *globalCapFile();
|
||||||
|
|
||||||
|
@ -87,6 +92,8 @@ signals:
|
||||||
void captureCaptureStopping(capture_session *cap_session);
|
void captureCaptureStopping(capture_session *cap_session);
|
||||||
void captureCaptureFailed(capture_session *cap_session);
|
void captureCaptureFailed(capture_session *cap_session);
|
||||||
|
|
||||||
|
void setCaptureStopFlag(bool);
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
|
|
|
@ -314,11 +314,13 @@ IOGraphDialog::IOGraphDialog(QWidget &parent, CaptureFile &cf) :
|
||||||
|
|
||||||
IOGraphDialog::~IOGraphDialog()
|
IOGraphDialog::~IOGraphDialog()
|
||||||
{
|
{
|
||||||
|
cap_file_.stopTapping();
|
||||||
for (int i = 0; i < ui->graphTreeWidget->topLevelItemCount(); i++) {
|
for (int i = 0; i < ui->graphTreeWidget->topLevelItemCount(); i++) {
|
||||||
IOGraph *iog = qvariant_cast<IOGraph *>(ui->graphTreeWidget->topLevelItem(i)->data(name_col_, Qt::UserRole));
|
IOGraph *iog = qvariant_cast<IOGraph *>(ui->graphTreeWidget->topLevelItem(i)->data(name_col_, Qt::UserRole));
|
||||||
delete iog;
|
delete iog;
|
||||||
}
|
}
|
||||||
delete ui;
|
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)
|
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_) {
|
if (need_retap_ && !file_closed_) {
|
||||||
need_retap_ = false;
|
need_retap_ = false;
|
||||||
cap_file_.retapPackets();
|
cap_file_.retapPackets();
|
||||||
ui->ioPlot->setFocus();
|
// The user might have closed the window while tapping, which means
|
||||||
|
// we might no longer exist.
|
||||||
} else {
|
} else {
|
||||||
if (need_recalc_ && !file_closed_) {
|
if (need_recalc_ && !file_closed_) {
|
||||||
need_recalc_ = false;
|
need_recalc_ = false;
|
||||||
|
|
|
@ -321,6 +321,9 @@ MainWindow::MainWindow(QWidget *parent) :
|
||||||
connect(&capture_file_, SIGNAL(captureFileClosed()),
|
connect(&capture_file_, SIGNAL(captureFileClosed()),
|
||||||
this, SLOT(captureFileClosed()));
|
this, SLOT(captureFileClosed()));
|
||||||
|
|
||||||
|
connect(&capture_file_, SIGNAL(setCaptureStopFlag(bool)),
|
||||||
|
this, SLOT(setCaptureStopFlag(bool)));
|
||||||
|
|
||||||
connect(&capture_file_, SIGNAL(captureFileReadStarted()),
|
connect(&capture_file_, SIGNAL(captureFileReadStarted()),
|
||||||
wsApp, SLOT(captureFileReadStarted()));
|
wsApp, SLOT(captureFileReadStarted()));
|
||||||
connect(&capture_file_, SIGNAL(captureFileReadFinished()),
|
connect(&capture_file_, SIGNAL(captureFileReadFinished()),
|
||||||
|
|
|
@ -193,6 +193,7 @@ public slots:
|
||||||
// in main_window_slots.cpp
|
// in main_window_slots.cpp
|
||||||
void openCaptureFile(QString& cf_path = *new QString(), QString& display_filter = *new QString(), unsigned int type = WTAP_TYPE_AUTO);
|
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 filterPackets(QString& new_filter = *new QString(), bool force = false);
|
||||||
|
void setCaptureStopFlag(bool stop_flag = true);
|
||||||
void updateForUnsavedChanges();
|
void updateForUnsavedChanges();
|
||||||
void layoutPanes();
|
void layoutPanes();
|
||||||
void applyRecentPaneGeometry();
|
void applyRecentPaneGeometry();
|
||||||
|
|
|
@ -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
|
// A new layout should be applied when it differs from the old layout AND
|
||||||
// at the following times:
|
// at the following times:
|
||||||
// - At startup
|
// - At startup
|
||||||
|
|
|
@ -184,6 +184,11 @@ progdlg_t * ProgressBar::show(bool animate, bool terminate_is_stop, gboolean *st
|
||||||
return &progress_dialog_;
|
return &progress_dialog_;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ProgressBar::setStopFlag(bool stop_flag)
|
||||||
|
{
|
||||||
|
if (stop_flag_) *stop_flag_ = stop_flag;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef QWINTASKBARPROGRESS_H
|
#ifdef QWINTASKBARPROGRESS_H
|
||||||
void ProgressBar::hide()
|
void ProgressBar::hide()
|
||||||
{
|
{
|
||||||
|
|
|
@ -51,6 +51,7 @@ public:
|
||||||
#ifdef QWINTASKBARPROGRESS_H
|
#ifdef QWINTASKBARPROGRESS_H
|
||||||
void hide();
|
void hide();
|
||||||
#endif
|
#endif
|
||||||
|
void setStopFlag(bool stop_flag);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
progdlg_t progress_dialog_;
|
progdlg_t progress_dialog_;
|
||||||
|
|
Loading…
Reference in New Issue