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/vncthread.cpp | 2 -- src/client/vnc/vncwindow.cpp | 12 +++++++++++- src/client/vnc/vncwindow.h | 1 + 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/src/client/vnc/vncthread.cpp b/src/client/vnc/vncthread.cpp index b710a2c..cafdace 100644 --- a/src/client/vnc/vncthread.cpp +++ b/src/client/vnc/vncthread.cpp @@ -202,8 +202,6 @@ void VncThread::run() while (_run) this->msleep(100); qDebug("[%s] VNC client stopped.", metaObject()->className()); - this->deleteLater(); - QThread::run(); } /** 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); diff --git a/src/client/vnc/vncwindow.h b/src/client/vnc/vncwindow.h index 3247b12..277339c 100644 --- a/src/client/vnc/vncwindow.h +++ b/src/client/vnc/vncwindow.h @@ -32,6 +32,7 @@ protected slots: void onProjectionStarted(); void onProjectionStopped(); void timer_moveToTop(); + void deleteVncThread(); void open(const QString& host, int port, const QString& passwd, bool ro, bool fullscreen, const QString& caption, const int clientId, const QByteArray& rawThumb); // bool close(); -- cgit v1.2.3-55-g7522