diff options
author | Simon Rettberg | 2017-12-04 17:28:01 +0100 |
---|---|---|
committer | Simon Rettberg | 2017-12-04 17:28:01 +0100 |
commit | 44212ee03b5fb74809decb89cb98e3fc2a86e928 (patch) | |
tree | fcd2ebd35d1ea20cca1631af77e0cf4e47783092 | |
parent | [server] Init qrand before creating main window, so session id is random (diff) | |
download | pvs2-44212ee03b5fb74809decb89cb98e3fc2a86e928.tar.gz pvs2-44212ee03b5fb74809decb89cb98e3fc2a86e928.tar.xz pvs2-44212ee03b5fb74809decb89cb98e3fc2a86e928.zip |
[client] Fix deletion of QThread while still running
-rw-r--r-- | src/client/vnc/vncthread.cpp | 2 | ||||
-rw-r--r-- | src/client/vnc/vncwindow.cpp | 12 | ||||
-rw-r--r-- | 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(); |