Don't start a core in CoreApplication's dtor... fixes BR #322
authorManuel Nickschas <sputnick@quassel-irc.org>
Mon, 22 Sep 2008 15:40:12 +0000 (17:40 +0200)
committerManuel Nickschas <sputnick@quassel-irc.org>
Mon, 22 Sep 2008 15:40:12 +0000 (17:40 +0200)
src/core/coreapplication.cpp
src/core/coreapplication.h

index d92e46d..7098ab8 100644 (file)
@@ -22,7 +22,9 @@
 
 #include "core.h"
 
 
 #include "core.h"
 
-CoreApplicationInternal::CoreApplicationInternal() {
+CoreApplicationInternal::CoreApplicationInternal() 
+  : _coreCreated(false)
+{
   // put core-only arguments here
   CliParser *parser = Quassel::cliParser();
   parser->addOption("port",'p', tr("The port quasselcore will listen at"), QString("4242"));
   // put core-only arguments here
   CliParser *parser = Quassel::cliParser();
   parser->addOption("port",'p', tr("The port quasselcore will listen at"), QString("4242"));
@@ -33,8 +35,10 @@ CoreApplicationInternal::CoreApplicationInternal() {
 }
 
 CoreApplicationInternal::~CoreApplicationInternal() {
 }
 
 CoreApplicationInternal::~CoreApplicationInternal() {
-  Core::saveState();
-  Core::destroy();
+  if(_coreCreated) {
+    Core::saveState();
+    Core::destroy();
+  }
 }
 
 bool CoreApplicationInternal::init() {
 }
 
 bool CoreApplicationInternal::init() {
@@ -51,6 +55,7 @@ bool CoreApplicationInternal::init() {
   }
 
   Core::instance();  // create and init the core
   }
 
   Core::instance();  // create and init the core
+  _coreCreated = true;
 
   if(!Quassel::isOptionSet("norestore")) {
     Core::restoreState();
 
   if(!Quassel::isOptionSet("norestore")) {
     Core::restoreState();
index 14eec29..07fa582 100644 (file)
@@ -36,6 +36,9 @@ class CoreApplicationInternal {
     ~CoreApplicationInternal();
 
     bool init();
     ~CoreApplicationInternal();
 
     bool init();
+    
+  private:
+    bool _coreCreated;
 };
 
 class CoreApplication : public QCoreApplication, public Quassel {
 };
 
 class CoreApplication : public QCoreApplication, public Quassel {