Catch recursion in message logger.
authorJesper Thomsch├╝tz <jesperht@yahoo.com>
Fri, 13 Mar 2009 22:41:21 +0000 (00:41 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Fri, 13 Mar 2009 23:31:50 +0000 (00:31 +0100)
src/client/client.cpp
src/client/client.h

index c2a3e16..ca219bb 100644 (file)
@@ -51,6 +51,11 @@ AccountId Client::_currentCoreAccount = 0;
 
 /*** Initialization/destruction ***/
 
+bool Client::instanceExists()
+{
+  return instanceptr;
+}
+
 Client *Client::instance() {
   if(!instanceptr)
     instanceptr = new Client();
@@ -496,6 +501,12 @@ void Client::logMessage(QtMsgType type, const char *msg) {
     Quassel::logFatalMessage(msg);
   } else {
     QString msgString = QString("%1\n").arg(msg);
+
+    //Check to see if there is an instance around, else we risk recursions
+    //when calling instance() and creating new ones.
+    if (!instanceExists())
+      return;
+
     instance()->_debugLog << msgString;
     emit instance()->logUpdated(msgString);
   }
index 3f5f79d..2821ab9 100644 (file)
@@ -62,6 +62,7 @@ public:
     RemoteCore
   };
 
+  static bool instanceExists();
   static Client *instance();
   static void destroy();
   static void init(AbstractUi *);