added zoom bar prototype
[presencevnc] / src / vncclientthread.cpp
index a9dab21..f66d189 100644 (file)
@@ -23,6 +23,7 @@
 
 #include "vncclientthread.h"
 
+#include <QCoreApplication>
 #include <QMutexLocker>
 #include <QTimer>
 
@@ -173,9 +174,10 @@ VncClientThread::~VncClientThread()
 
     const bool quitSuccess = wait(500);
 
-    kDebug(5011) << "Quit VNC thread success:" << quitSuccess;
+    kDebug(5011) << "~VncClientThread(): Quit VNC thread success:" << quitSuccess;
     
     delete [] frameBuffer;
+    //cl is free()d when event loop exits.
 }
 
 void VncClientThread::checkOutputErrorMessage()
@@ -240,7 +242,7 @@ 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.
     m_stopped = true;
 }
 
@@ -248,6 +250,7 @@ void VncClientThread::run()
 {
     QMutexLocker locker(&mutex);
 
+    int passwd_failures = 0;
     while (!m_stopped) { // try to connect as long as the server allows
         m_passwordError = false;
 
@@ -275,8 +278,12 @@ void VncClientThread::run()
         if (rfbInitClient(cl, 0, 0))
             break;
 
-        if (m_passwordError)
+        if (m_passwordError) {
+           passwd_failures++;
+           if(passwd_failures > 2)
+                   m_stopped = true;
             continue;
+       }
 
         return;
     }