From debc206f20da1211e18c946464ec9f8768832670 Mon Sep 17 00:00:00 2001 From: Christian Pulvermacher Date: Wed, 6 Oct 2010 10:42:03 +0200 Subject: [PATCH] trying to pinpoint crash on exit --- src/vncclientthread.cpp | 30 +++++++++++++++++++++++++++--- src/vncclientthread.h | 1 + src/vncview.cpp | 3 ++- 3 files changed, 30 insertions(+), 4 deletions(-) diff --git a/src/vncclientthread.cpp b/src/vncclientthread.cpp index 7899453..2954084 100644 --- a/src/vncclientthread.cpp +++ b/src/vncclientthread.cpp @@ -78,7 +78,7 @@ rfbBool VncClientThread::newclient(rfbClient *cl) void VncClientThread::updatefb(rfbClient* cl, int x, int y, int w, int h) { -// kDebug(5011) << "updated client: x: " << x << ", y: " << y << ", w: " << w << ", h: " << h; + //kDebug(5011) << "updated client: x: " << x << ", y: " << y << ", w: " << w << ", h: " << h; const int width = cl->width, height = cl->height; @@ -172,12 +172,16 @@ VncClientThread::~VncClientThread() { stop(); - const bool quitSuccess = wait(500); + const bool quitSuccess = wait(1000); kDebug(5011) << "~VncClientThread(): Quit VNC thread success:" << quitSuccess; delete [] frameBuffer; //cl is free()d when event loop exits. + + kDebug(5011) << "inMessageHandler: " << inMessageHandler; + + kDebug(5011) << "leaving ~VncClientThreod()"; } void VncClientThread::checkOutputErrorMessage() @@ -242,7 +246,10 @@ void VncClientThread::emitGotCut(const QString &text) void VncClientThread::stop() { + QMutexLocker locker(&mutex); //TODO: not locking the mutex leads to a crash, but at least it stops. +//TODO: i don't see how this makes a difference + kDebug(5011) << "stop(): mutex locked"; m_stopped = true; } @@ -293,14 +300,28 @@ void VncClientThread::run() locker.unlock(); + inMessageHandler = false; + // Main VNC event loop while (!m_stopped) { const int i = WaitForMessage(cl, 500); if (i < 0) break; - if (i) + if(m_stopped) { + kDebug(5011) << "foo2"; + break; + } + if (i) { + inMessageHandler = true; if (!HandleRFBServerMessage(cl)) break; + inMessageHandler = false; + } + + if(m_stopped) { + kDebug(5011) << "foo4"; + break; + } locker.relock(); @@ -312,12 +333,15 @@ void VncClientThread::run() locker.unlock(); } + kDebug(5011) << "exited main loop"; // Cleanup allocated resources locker.relock(); + kDebug(5011) << "mutex relocked"; if(!clean) rfbClientCleanup(cl); m_stopped = true; + kDebug(5011) << "exiting run()"; } ClientEvent::~ClientEvent() diff --git a/src/vncclientthread.h b/src/vncclientthread.h index 6940cad..7135003 100644 --- a/src/vncclientthread.h +++ b/src/vncclientthread.h @@ -149,6 +149,7 @@ private: volatile bool m_stopped; volatile bool m_passwordError; + bool inMessageHandler; private slots: void checkOutputErrorMessage(); diff --git a/src/vncview.cpp b/src/vncview.cpp index 8152bec..9d3866b 100644 --- a/src/vncview.cpp +++ b/src/vncview.cpp @@ -166,12 +166,13 @@ void VncView::startQuitting() m_quitFlag = true; if (connected) { + kDebug(5011) << "stopping vncThread"; vncThread.stop(); } vncThread.quit(); - const bool quitSuccess = vncThread.wait(500); + const bool quitSuccess = vncThread.wait(700); kDebug(5011) << "startQuitting(): Quit VNC thread success:" << quitSuccess; -- 1.7.9.5