[rkward-cvs] SF.net SVN: rkward-code:[4975] trunk/rkward/rkward/main.cpp

tfry at users.sf.net tfry at users.sf.net
Wed Oct 29 10:05:08 UTC 2014


Revision: 4975
          http://sourceforge.net/p/rkward/code/4975
Author:   tfry
Date:     2014-10-29 10:05:06 +0000 (Wed, 29 Oct 2014)
Log Message:
-----------
Protect debug message window against receving messages from wrong thread

Modified Paths:
--------------
    trunk/rkward/rkward/main.cpp

Modified: trunk/rkward/rkward/main.cpp
===================================================================
--- trunk/rkward/rkward/main.cpp	2014-10-29 10:04:04 UTC (rev 4974)
+++ trunk/rkward/rkward/main.cpp	2014-10-29 10:05:06 UTC (rev 4975)
@@ -59,6 +59,7 @@
 #include <QMutex>
 #include <QTemporaryFile>
 #include <QDir>
+#include <QThread>
 
 #include <stdio.h>
 #include <stdlib.h>
@@ -97,8 +98,8 @@
 }
 
 /** The point of this redirect (to be called via the RK_DEBUG() macro) is to separate RKWard specific debug messages from
- * any other noise, coming from Qt / kdelibs. Also it allows us to retain info on flags and level. Eventually, this could
- * be made available in a tool window, esp. for debugging plugins. */
+ * any other noise, coming from Qt / kdelibs. Also it allows us to retain info on flags and level, and to show messages
+ * in a tool window, esp. for debugging plugins. */
 void RKDebug (int flags, int level, const char *fmt, ...) {
 	const int bufsize = 1024*8;
 	char buffer[bufsize];
@@ -108,7 +109,10 @@
 	vsnprintf (buffer, bufsize-1, fmt, ap);
 	va_end (ap);
 	RKDebugMessageOutput (QtDebugMsg, buffer);
-	RKDebugMessageWindow::newMessage (flags, level, QString (buffer));
+	if (QApplication::instance ()->thread () == QThread::currentThread ()) {
+		// not safe to call from any other than the GUI thread
+		RKDebugMessageWindow::newMessage (flags, level, QString (buffer));
+	}
 }
 
 QString decodeArgument (const QString &input) {





More information about the rkward-tracker mailing list