diff options
author | Jirka Novak <j.novak@netsystem.cz> | 2021-05-09 16:29:11 +0200 |
---|---|---|
committer | j.novak@netsystem.cz <j.novak@netsystem.cz> | 2021-05-22 03:08:46 +0000 |
commit | c01456b77e3bc329b761e907460ce725730466b3 (patch) | |
tree | abc0d186f00eb6dd166760d09dd00b53c0a8189b /ui/qt/rtp_analysis_dialog.cpp | |
parent | c22b857942ea3f123d9fa5c31e04e85c6f3928f5 (diff) |
VoIP Dialogs: Refactoring of singleton windows to factory methods
Singletons moved from main_window to each class's static open<NameOfClass>
method:
- RtpPlayerDialog
- RtpStreamDialog
- VoipCallsDialog
- RtpAnalysisDialog
Fixed issue with selecting RTP stream in sequence dialog. When user
selected a stream and moved mouse to Rtp Player button and pressed it,
incorrect RTP stream was sent to it.
Diffstat (limited to 'ui/qt/rtp_analysis_dialog.cpp')
-rw-r--r-- | ui/qt/rtp_analysis_dialog.cpp | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/ui/qt/rtp_analysis_dialog.cpp b/ui/qt/rtp_analysis_dialog.cpp index 2a345d0758..920d8cab94 100644 --- a/ui/qt/rtp_analysis_dialog.cpp +++ b/ui/qt/rtp_analysis_dialog.cpp @@ -239,6 +239,21 @@ enum { num_graphs_ }; +RtpAnalysisDialog *RtpAnalysisDialog::pinstance_{nullptr}; +std::mutex RtpAnalysisDialog::mutex_; + +RtpAnalysisDialog *RtpAnalysisDialog::openRtpAnalysisDialog(QWidget &parent, CaptureFile &cf, QObject *packet_list) +{ + std::lock_guard<std::mutex> lock(mutex_); + if (pinstance_ == nullptr) + { + pinstance_ = new RtpAnalysisDialog(parent, cf); + connect(pinstance_, SIGNAL(goToPacket(int)), + packet_list, SLOT(goToPacket(int))); + } + return pinstance_; +} + RtpAnalysisDialog::RtpAnalysisDialog(QWidget &parent, CaptureFile &cf) : WiresharkDialog(parent, cf), ui(new Ui::RtpAnalysisDialog), @@ -285,6 +300,14 @@ RtpAnalysisDialog::RtpAnalysisDialog(QWidget &parent, CaptureFile &cf) : this, SLOT(updateWidgets())); connect(ui->tabWidget->tabBar(), SIGNAL(tabCloseRequested(int)), this, SLOT(closeTab(int))); + connect(this, SIGNAL(updateFilter(QString, bool)), + &parent, SLOT(filterPackets(QString, bool))); + connect(this, SIGNAL(rtpPlayerDialogReplaceRtpStreams(QVector<rtpstream_id_t *>)), + &parent, SLOT(rtpPlayerDialogReplaceRtpStreams(QVector<rtpstream_id_t *>))); + connect(this, SIGNAL(rtpPlayerDialogAddRtpStreams(QVector<rtpstream_id_t *>)), + &parent, SLOT(rtpPlayerDialogAddRtpStreams(QVector<rtpstream_id_t *>))); + connect(this, SIGNAL(rtpPlayerDialogRemoveRtpStreams(QVector<rtpstream_id_t *>)), + &parent, SLOT(rtpPlayerDialogRemoveRtpStreams(QVector<rtpstream_id_t *>))); updateWidgets(); @@ -293,11 +316,13 @@ RtpAnalysisDialog::RtpAnalysisDialog(QWidget &parent, CaptureFile &cf) : RtpAnalysisDialog::~RtpAnalysisDialog() { + std::lock_guard<std::mutex> lock(mutex_); delete ui; for(int i=0; i<tabs_.count(); i++) { deleteTabInfo(tabs_[i]); g_free(tabs_[i]); } + pinstance_ = nullptr; } void RtpAnalysisDialog::deleteTabInfo(tab_info_t *tab_info) @@ -970,6 +995,7 @@ void RtpAnalysisDialog::showStreamMenu(QPoint pos) void RtpAnalysisDialog::replaceRtpStreams(QVector<rtpstream_id_t *> stream_ids) { + std::lock_guard<std::mutex> lock(mutex_); // Delete existing tabs (from last to first) if (tabs_.count() > 0) { for(int i=tabs_.count(); i>0; i--) { @@ -981,6 +1007,7 @@ void RtpAnalysisDialog::replaceRtpStreams(QVector<rtpstream_id_t *> stream_ids) void RtpAnalysisDialog::addRtpStreams(QVector<rtpstream_id_t *> stream_ids) { + std::lock_guard<std::mutex> lock(mutex_); addRtpStreamsPrivate(stream_ids); } @@ -1031,6 +1058,7 @@ void RtpAnalysisDialog::addRtpStreamsPrivate(QVector<rtpstream_id_t *> stream_id void RtpAnalysisDialog::removeRtpStreams(QVector<rtpstream_id_t *> stream_ids) { + std::lock_guard<std::mutex> lock(mutex_); setUpdatesEnabled(false); foreach(rtpstream_id_t *id, stream_ids) { QList<tab_info_t *> tabs = tab_hash_.values(rtpstream_id_to_hash(id)); |