summaryrefslogtreecommitdiff
path: root/ui/qt/rtp_player_dialog.cpp
diff options
context:
space:
mode:
authorPeter Wu <peter@lekensteyn.nl>2015-11-17 18:54:41 +0100
committerGerald Combs <gerald@wireshark.org>2015-11-17 22:49:35 +0000
commit0fef9d752f801986a81b7c294143eae21cd0de97 (patch)
treed1528b47b44fd5ca9f459ba8374618f6ce6a19d1 /ui/qt/rtp_player_dialog.cpp
parente3eb9f32081dafd97e058bf292e130e511f33748 (diff)
downloadwireshark-0fef9d752f801986a81b7c294143eae21cd0de97.tar.gz
Fix crash in RTP Player on stop and close
When dragging the UI, this somehow causes a great lag. Then by spam-clicking on the Stop button, a double free seems to occur. Fix this by moving the audio cleanup to the outputStateChanged callback as documented at https://doc.qt.io/qt-5/qaudiooutput.html. Note that calling stop() in the IdleState also triggers a change event, resulting in the desired cleanup. Stop streams before the dialog is closed (via accept/reject). This *cannot* be done in the destrutor of RtpPlayerDialog because destructing QAudioOutput processes events from the event queue, resulting in preature destruction of other objects... crash. Change-Id: I6bfb33c9396e9bc1ffd346519d22390a97b6bdaf Reviewed-on: https://code.wireshark.org/review/11894 Petri-Dish: Peter Wu <peter@lekensteyn.nl> Tested-by: Petri Dish Buildbot <buildbot-no-reply@wireshark.org> Reviewed-by: Gerald Combs <gerald@wireshark.org>
Diffstat (limited to 'ui/qt/rtp_player_dialog.cpp')
-rw-r--r--ui/qt/rtp_player_dialog.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/ui/qt/rtp_player_dialog.cpp b/ui/qt/rtp_player_dialog.cpp
index e5545c99d9..9b26c1fb5a 100644
--- a/ui/qt/rtp_player_dialog.cpp
+++ b/ui/qt/rtp_player_dialog.cpp
@@ -177,6 +177,23 @@ RtpPlayerDialog::~RtpPlayerDialog()
delete ui;
}
+void RtpPlayerDialog::accept()
+{
+ int row_count = ui->streamTreeWidget->topLevelItemCount();
+ // Stop all streams before the dialogs are closed.
+ for (int row = 0; row < row_count; row++) {
+ QTreeWidgetItem *ti = ui->streamTreeWidget->topLevelItem(row);
+ RtpAudioStream *audio_stream = ti->data(stream_data_col_, Qt::UserRole).value<RtpAudioStream*>();
+ audio_stream->stopPlaying();
+ }
+ WiresharkDialog::accept();
+}
+
+void RtpPlayerDialog::reject()
+{
+ RtpPlayerDialog::accept();
+}
+
void RtpPlayerDialog::retapPackets()
{
register_tap_listener("rtp", this, NULL, 0, NULL, tapPacket, NULL);