Qt framework: Dialogs are correctly notified when capture file was closed

The patch reintroduces WiresharkDialog::captureFileClosed() method and
calls captureFileClosing() and captureFileClosed() in right order.
Both methods call updateWidgets() at its end.

All dialogs were reviewed and captureFileClosing/Closed methods updated
when appropriate.
captureEvent() method in multiple dialogs changed to captureFileClosing/Closed
as it does same actions - looks like old style of detecting of capture
file closing.
This commit is contained in:
Jirka Novak 2021-01-10 21:57:47 +01:00 committed by AndersBroman
parent aad42108e0
commit 8dd8491713
34 changed files with 100 additions and 87 deletions

View File

@ -96,13 +96,13 @@ BluetoothAttServerAttributesDialog::~BluetoothAttServerAttributesDialog()
}
void BluetoothAttServerAttributesDialog::captureFileClosing()
void BluetoothAttServerAttributesDialog::captureFileClosed()
{
ui->interfaceComboBox->setEnabled(FALSE);
ui->deviceComboBox->setEnabled(FALSE);
ui->removeDuplicatesCheckBox->setEnabled(FALSE);
WiresharkDialog::captureFileClosing();
WiresharkDialog::captureFileClosed();
}

View File

@ -53,6 +53,7 @@ signals:
protected:
void keyPressEvent(QKeyEvent *event);
void captureFileClosed();
protected slots:
void changeEvent(QEvent* event);
@ -67,7 +68,6 @@ private:
static tap_packet_status tapPacket(void *tapinfo_ptr, packet_info *pinfo, epan_dissect_t *, const void *data);
private slots:
void captureFileClosing();
void on_tableTreeWidget_itemActivated(QTreeWidgetItem *item, int);
void on_buttonBox_clicked(QAbstractButton *button);
void on_actionMark_Unmark_Cell_triggered();

View File

@ -67,6 +67,7 @@ signals:
protected:
void keyPressEvent(QKeyEvent *event);
void captureFileClosing();
protected slots:
void changeEvent(QEvent* event);
@ -84,7 +85,6 @@ private:
static void saveItemData(QTableWidgetItem *item, bluetooth_device_tap_t *tap_device, packet_info *pinfo);
private slots:
void captureFileClosing();
void setTitle(QString bdAddr, QString name);
void on_tableWidget_itemActivated(QTableWidgetItem *item);
void on_buttonBox_clicked(QAbstractButton *button);

View File

@ -110,12 +110,12 @@ BluetoothDevicesDialog::~BluetoothDevicesDialog()
}
void BluetoothDevicesDialog::captureFileClosing()
void BluetoothDevicesDialog::captureFileClosed()
{
ui->interfaceComboBox->setEnabled(FALSE);
ui->showInformationStepsCheckBox->setEnabled(FALSE);
WiresharkDialog::captureFileClosing();
WiresharkDialog::captureFileClosed();
}

View File

@ -53,6 +53,7 @@ signals:
protected:
void keyPressEvent(QKeyEvent *event);
void captureFileClosed();
protected slots:
void changeEvent(QEvent* event);
@ -68,7 +69,6 @@ private:
static tap_packet_status tapPacket(void *tapinfo_ptr, packet_info *pinfo, epan_dissect_t *, const void *data);
private slots:
void captureFileClosing();
void on_tableTreeWidget_itemActivated(QTreeWidgetItem *item, int);
void on_buttonBox_clicked(QAbstractButton *button);
void on_actionMark_Unmark_Cell_triggered();

View File

@ -151,10 +151,16 @@ void BluetoothHciSummaryDialog::captureFileClosing()
{
remove_tap_listener(&tapinfo_);
WiresharkDialog::captureFileClosing();
}
void BluetoothHciSummaryDialog::captureFileClosed()
{
ui->interfaceComboBox->setEnabled(FALSE);
ui->adapterComboBox->setEnabled(FALSE);
WiresharkDialog::captureFileClosing();
WiresharkDialog::captureFileClosed();
}

View File

@ -53,6 +53,8 @@ signals:
protected:
void keyPressEvent(QKeyEvent *event);
void captureFileClosing();
void captureFileClosed();
protected slots:
void changeEvent(QEvent* event);
@ -82,7 +84,6 @@ private:
static tap_packet_status tapPacket(void *tapinfo_ptr, packet_info *pinfo, epan_dissect_t *, const void *data);
private slots:
void captureFileClosing();
void recursiveCopyTreeItems(QTreeWidgetItem *item, QString &copy, int ident_level);
void on_tableTreeWidget_itemActivated(QTreeWidgetItem *item, int);
void on_buttonBox_clicked(QAbstractButton *button);

View File

@ -135,11 +135,16 @@ void ConversationDialog::captureFileClosing()
disconnect(cur_tree, SIGNAL(filterAction(QString,FilterAction::Action,FilterAction::ActionType)),
this, SIGNAL(filterAction(QString,FilterAction::Action,FilterAction::ActionType)));
}
TrafficTableDialog::captureFileClosing();
}
void ConversationDialog::captureFileClosed()
{
displayFilterCheckBox()->setEnabled(false);
enabledTypesPushButton()->setEnabled(false);
follow_bt_->setEnabled(false);
graph_bt_->setEnabled(false);
TrafficTableDialog::captureFileClosing();
TrafficTableDialog::captureFileClosed();
}
bool ConversationDialog::addTrafficTable(register_ct_t* table)

View File

@ -52,8 +52,9 @@ public:
explicit ConversationDialog(QWidget &parent, CaptureFile &cf, int cli_proto_id = -1, const char *filter = NULL);
~ConversationDialog();
public slots:
protected:
void captureFileClosing();
void captureFileClosed();
signals:
void filterAction(QString filter, FilterAction::Action action, FilterAction::ActionType type);

View File

@ -117,9 +117,14 @@ void EndpointDialog::captureFileClosing()
disconnect(cur_tree, SIGNAL(filterAction(QString,FilterAction::Action,FilterAction::ActionType)),
this, SIGNAL(filterAction(QString,FilterAction::Action,FilterAction::ActionType)));
}
TrafficTableDialog::captureFileClosing();
}
void EndpointDialog::captureFileClosed()
{
displayFilterCheckBox()->setEnabled(false);
enabledTypesPushButton()->setEnabled(false);
TrafficTableDialog::captureFileClosing();
TrafficTableDialog::captureFileClosed();
}
bool EndpointDialog::addTrafficTable(register_ct_t *table)

View File

@ -59,8 +59,9 @@ public:
signals:
public slots:
protected:
void captureFileClosing();
void captureFileClosed();
private:
#ifdef HAVE_MAXMINDDB

View File

@ -144,8 +144,6 @@ FollowStreamDialog::FollowStreamDialog(QWidget &parent, CaptureFile &cf, follow_
this, SLOT(fillHintLabel(int)));
connect(ui->teStreamContent, SIGNAL(mouseClickedOnTextCursorPosition(int)),
this, SLOT(goToPacketForTextPos(int)));
connect(&cap_file_, SIGNAL(captureEvent(CaptureEvent)),
this, SLOT(captureEvent(CaptureEvent)));
fillHintLabel(-1);
}
@ -1061,15 +1059,12 @@ bool FollowStreamDialog::follow(QString previous_filter, bool use_stream_index,
return true;
}
void FollowStreamDialog::captureEvent(CaptureEvent e)
void FollowStreamDialog::captureFileClosed()
{
if ((e.captureContext() == CaptureEvent::File) &&
(e.eventType() == CaptureEvent::Closing)) {
QString tooltip = tr("File closed.");
ui->streamNumberSpinBox->setToolTip(tooltip);
ui->streamNumberLabel->setToolTip(tooltip);
WiresharkDialog::captureFileClosing();
}
QString tooltip = tr("File closed.");
ui->streamNumberSpinBox->setToolTip(tooltip);
ui->streamNumberLabel->setToolTip(tooltip);
WiresharkDialog::captureFileClosed();
}
/*

View File

@ -45,12 +45,10 @@ public:
void addCodecs(const QMap<QString, QTextCodec *> &codecMap);
bool follow(QString previous_filter = QString(), bool use_stream_index = false, guint stream_num = 0, guint sub_stream_num = 0);
public slots:
void captureEvent(CaptureEvent e);
protected:
bool eventFilter(QObject *obj, QEvent *event);
void keyPressEvent(QKeyEvent *event);
void captureFileClosed();
private slots:
void on_cbCharset_currentIndexChanged(int idx);

View File

@ -391,8 +391,6 @@ Iax2AnalysisDialog::Iax2AnalysisDialog(QWidget &parent, CaptureFile &cf) :
this, SLOT(updateWidgets()));
connect(ui->reverseTreeWidget, SIGNAL(itemSelectionChanged()),
this, SLOT(updateWidgets()));
connect(&cap_file_, SIGNAL(captureEvent(CaptureEvent)),
this, SLOT(captureEvent(CaptureEvent)));
updateWidgets();
registerTapListener("IAX2", this, Q_NULLPTR, 0, tapReset, tapPacket, tapDraw);
@ -410,15 +408,6 @@ Iax2AnalysisDialog::~Iax2AnalysisDialog()
delete rev_tempfile_;
}
void Iax2AnalysisDialog::captureEvent(CaptureEvent e)
{
if ((e.captureContext() == CaptureEvent::File) &&
(e.eventType() == CaptureEvent::Closing))
{
updateWidgets();
}
}
void Iax2AnalysisDialog::updateWidgets()
{
bool enable_tab = false;

View File

@ -56,7 +56,6 @@ signals:
void goToPacket(int packet_num);
protected slots:
void captureEvent(CaptureEvent e);
virtual void updateWidgets();
private slots:

View File

@ -866,7 +866,6 @@ void LteMacStatisticsDialog::updateHeaderLabels()
void LteMacStatisticsDialog::captureFileClosing()
{
remove_tap_listener(this);
updateWidgets();
WiresharkDialog::captureFileClosing();
}

View File

@ -43,6 +43,7 @@ public:
~LteMacStatisticsDialog();
protected:
void captureFileClosing();
private:
// Extra controls needed for this dialog.
@ -73,7 +74,6 @@ private:
private slots:
virtual void fillTree();
void updateHeaderLabels();
void captureFileClosing();
void filterUpdated(QString filter);
};

View File

@ -915,7 +915,6 @@ void LteRlcStatisticsDialog::updateHeaderLabels()
void LteRlcStatisticsDialog::captureFileClosing()
{
remove_tap_listener(this);
updateWidgets();
WiresharkDialog::captureFileClosing();
}

View File

@ -26,6 +26,7 @@ public:
void incFrameCount() { ++packet_count_; }
protected:
void captureFileClosing();
signals:
void launchRLCGraph(bool channelKnown,
@ -60,8 +61,6 @@ private slots:
virtual void fillTree();
void updateItemSelectionChanged();
void captureFileClosing();
void useRLCFramesFromMacCheckBoxToggled(bool state);
void launchULGraphButtonClicked();
void launchDLGraphButtonClicked();

View File

@ -243,9 +243,6 @@ MulticastStatisticsDialog::MulticastStatisticsDialog(QWidget &parent, CaptureFil
connect(this, SIGNAL(updateFilter(QString)),
this, SLOT(updateMulticastParameters()));
connect(&cap_file_, SIGNAL(captureEvent(CaptureEvent)),
this, SLOT(captureEvent(CaptureEvent)));
/* Register the tap listener */
register_tap_listener_mcast_stream(tapinfo_);
@ -449,17 +446,12 @@ void MulticastStatisticsDialog::fillTree()
updateWidgets();
}
void MulticastStatisticsDialog::captureEvent(CaptureEvent e)
void MulticastStatisticsDialog::captureFileClosing()
{
if ((e.captureContext() == CaptureEvent::File) &&
(e.eventType() == CaptureEvent::Closing))
{
/* Remove the stream tap listener */
remove_tap_listener_mcast_stream(tapinfo_);
/* Remove the stream tap listener */
remove_tap_listener_mcast_stream(tapinfo_);
updateWidgets();
WiresharkDialog::captureFileClosing();
}
WiresharkDialog::captureFileClosing();
}
// Stat command + args

View File

@ -23,6 +23,9 @@ public:
MulticastStatisticsDialog(QWidget &parent, CaptureFile &cf, const char *filter = NULL);
~MulticastStatisticsDialog();
protected:
void captureFileClosing();
private:
struct _mcaststream_tapinfo *tapinfo_;
SyntaxLineEdit *burst_measurement_interval_le_;
@ -43,7 +46,6 @@ private slots:
void updateWidgets();
void updateMulticastParameters();
virtual void fillTree();
void captureEvent(CaptureEvent e);
};
#endif // MULTICASTSTATISTICSDIALOG_H

View File

@ -33,6 +33,9 @@ public:
explicit PacketDialog(QWidget &parent, CaptureFile &cf, frame_data *fdata);
~PacketDialog();
protected:
void captureFileClosing();
signals:
void showProtocolPreferences(const QString module_name);
void editProtocolPreference(struct preference *pref, struct pref_module *module);
@ -40,7 +43,6 @@ signals:
private slots:
void on_buttonBox_helpRequested();
void captureFileClosing();
void setHintText(FieldInformation *);
private:

View File

@ -391,12 +391,6 @@ RtpAnalysisDialog::~RtpAnalysisDialog()
delete rev_tempfile_;
}
// TODO: Can be removed if not used to fix issue with disabling buttons
void RtpAnalysisDialog::captureFileClosing()
{
WiresharkDialog::captureFileClosing();
}
void RtpAnalysisDialog::updateWidgets()
{
bool enable_tab = false;

View File

@ -44,9 +44,6 @@ public:
signals:
void goToPacket(int packet_num);
protected:
virtual void captureFileClosing();
protected slots:
virtual void updateWidgets();

View File

@ -543,14 +543,19 @@ QList<QVariant> RtpStreamDialog::streamRowData(int row) const
void RtpStreamDialog::captureFileClosing()
{
ui->todCheckBox->setEnabled(false);
ui->displayFilterCheckBox->setEnabled(false);
remove_tap_listener_rtpstream(&tapinfo_);
WiresharkDialog::captureFileClosing();
}
void RtpStreamDialog::captureFileClosed()
{
ui->todCheckBox->setEnabled(false);
ui->displayFilterCheckBox->setEnabled(false);
WiresharkDialog::captureFileClosed();
}
void RtpStreamDialog::showStreamMenu(QPoint pos)
{
ui->actionGoToSetup->setEnabled(!file_closed_);

View File

@ -45,6 +45,8 @@ public slots:
protected:
bool eventFilter(QObject *obj, QEvent *event);
void captureFileClosing();
void captureFileClosed();
private:
Ui::RtpStreamDialog *ui;
@ -72,7 +74,6 @@ private:
private slots:
void captureFileClosing();
void showStreamMenu(QPoint pos);
void on_actionCopyAsCsv_triggered();
void on_actionCopyAsYaml_triggered();

View File

@ -759,6 +759,13 @@ void ShowPacketBytesDialog::updatePacketBytes(void)
}
void ShowPacketBytesDialog::captureFileClosing()
{
finfo_ = NULL; // This will invalidate the source backend
WiresharkDialog::captureFileClosing();
}
void ShowPacketBytesDialog::captureFileClosed()
{
// We have lost the source backend and must disable all functions
// for manipulating decoding and displayed range.
@ -771,9 +778,7 @@ void ShowPacketBytesDialog::captureFileClosing()
ui->lEnd->setEnabled(false);
ui->sbEnd->setEnabled(false);
finfo_ = NULL; // This will invalidate the source backend
WiresharkDialog::captureFileClosing();
WiresharkDialog::captureFileClosed();
}
void ShowPacketBytesTextEdit::contextMenuEvent(QContextMenuEvent *event)

View File

@ -40,12 +40,11 @@ public:
void addCodecs(const QMap<QString, QTextCodec *> &codecMap);
public slots:
void captureFileClosing();
protected:
bool eventFilter(QObject *obj, QEvent *event);
void keyPressEvent(QKeyEvent *event);
void captureFileClosing();
void captureFileClosed();
private slots:
void on_sbStart_valueChanged(int value);

View File

@ -140,9 +140,7 @@ void VoipCallsDialog::captureFileClosing()
{
// The time formatting is currently provided by VoipCallsInfoModel, but when
// the cache is active, the ToD cannot be modified.
ui->todCheckBox->setEnabled(false);
cache_model_->setSourceModel(NULL);
ui->displayFilterCheckBox->setEnabled(false);
if (!voip_calls_tap_listeners_removed_) {
voip_calls_remove_all_tap_listeners(&tapinfo_);
voip_calls_tap_listeners_removed_ = true;
@ -152,6 +150,16 @@ void VoipCallsDialog::captureFileClosing()
WiresharkDialog::captureFileClosing();
}
void VoipCallsDialog::captureFileClosed()
{
// The time formatting is currently provided by VoipCallsInfoModel, but when
// the cache is active, the ToD cannot be modified.
ui->todCheckBox->setEnabled(false);
ui->displayFilterCheckBox->setEnabled(false);
WiresharkDialog::captureFileClosed();
}
void VoipCallsDialog::contextMenuEvent(QContextMenuEvent *event)
{
bool selected = ui->callTreeView->selectionModel()->hasSelection();

View File

@ -55,6 +55,8 @@ public slots:
protected:
void contextMenuEvent(QContextMenuEvent *event);
virtual void removeTapListeners();
void captureFileClosing();
void captureFileClosed();
protected slots:
void changeEvent(QEvent* event);
@ -90,7 +92,6 @@ private:
QList<QVariant> streamRowData(int row) const;
private slots:
void captureFileClosing();
void selectAll();
void selectNone();
void copyAsCSV();

View File

@ -135,8 +135,8 @@ void WiresharkDialog::captureEvent(CaptureEvent e)
captureFileClosing();
break;
case CaptureEvent::Closed:
captureFileClosing();
file_closed_ = true;
captureFileClosed();
break;
default:
break;
@ -168,13 +168,15 @@ void WiresharkDialog::removeTapListeners()
void WiresharkDialog::captureFileClosing()
{
if (file_closed_)
return;
removeTapListeners();
updateWidgets();
}
void WiresharkDialog::captureFileClosed()
{
updateWidgets();
}
/*
* Editor modelines
*

View File

@ -117,11 +117,20 @@ protected:
/**
* @brief Called when the capture file is about to close. This can be
* used to enable or disable widgets according to the state of
* file_closed_.
* used to disconnect taps and similar actions.
* updateWidgets() is called at the end.
* To enable/disable widgets captureFileClosed() is more suitable.
*/
virtual void captureFileClosing();
/**
* @brief Called when the capture file was closed. This can be
* used to enable or disable widgets according to the state of
* file_closed_.
* updateWidgets() is called at the end.
*/
virtual void captureFileClosed();
protected slots:
void captureEvent(CaptureEvent);

View File

@ -693,7 +693,6 @@ void WlanStatisticsDialog::updateHeaderLabels()
void WlanStatisticsDialog::captureFileClosing()
{
remove_tap_listener(this);
updateWidgets();
WiresharkDialog::captureFileClosing();
}

View File

@ -24,6 +24,7 @@ public:
~WlanStatisticsDialog();
protected:
void captureFileClosing();
private:
int packet_count_;
@ -46,7 +47,6 @@ private slots:
virtual void fillTree();
void addStationTreeItems();
void updateHeaderLabels();
void captureFileClosing();
void filterUpdated(QString filter);
};