From 44212ee03b5fb74809decb89cb98e3fc2a86e928 Mon Sep 17 00:00:00 2001 From: Simon Rettberg Date: Mon, 4 Dec 2017 17:28:01 +0100 Subject: [client] Fix deletion of QThread while still running --- src/client/vnc/vncwindow.cpp | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) (limited to 'src/client/vnc/vncwindow.cpp') diff --git a/src/client/vnc/vncwindow.cpp b/src/client/vnc/vncwindow.cpp index 0854f01..c9c0d93 100644 --- a/src/client/vnc/vncwindow.cpp +++ b/src/client/vnc/vncwindow.cpp @@ -49,7 +49,10 @@ void VncWindow::terminateVncThread() if (_vncWorker == NULL) return; - _vncWorker->blockSignals(true); + disconnect(_vncWorker, SIGNAL(projectionStopped()), this, SLOT(onProjectionStopped())); + disconnect(_vncWorker, SIGNAL(projectionStarted()), this, SLOT(onProjectionStarted())); + disconnect(_vncWorker, SIGNAL(imageUpdated(const int, const int, const int, const int)), this, + SLOT(onUpdateImage(const int, const int, const int, const int))); _vncWorker->stop(); _vncWorker = NULL; if (_redrawTimer != 0) { @@ -62,6 +65,12 @@ void VncWindow::terminateVncThread() } } +void VncWindow::deleteVncThread() +{ + qDebug() << "Deleting thread" << QObject::sender(); + delete QObject::sender(); +} + /** * Draws given part of the current VNC frame buffer to the window. * Gets the image from the _vncWorker thread in an unsafe way. :( @@ -106,6 +115,7 @@ void VncWindow::open(const QString& host, int port, const QString& passwd, bool connect(_vncWorker, SIGNAL(imageUpdated(const int, const int, const int, const int)), this, SLOT(onUpdateImage(const int, const int, const int, const int)), Qt::QueuedConnection); + connect(_vncWorker, SIGNAL(finished()), this, SLOT(deleteVncThread()), Qt::QueuedConnection); setWindowTitle(caption); -- cgit v1.2.3-55-g7522