Account: Destroy on exit.
authorChristian Kamm <kamm@incasoftware.de>
Fri, 27 Mar 2015 09:30:35 +0000 (10:30 +0100)
committerChristian Kamm <kamm@incasoftware.de>
Fri, 27 Mar 2015 09:43:14 +0000 (10:43 +0100)
During shutdown we want the account object to be deleted and
therefore we need to be able to remove the strong reference
in AccountManager.

src/gui/accountstate.cpp
src/gui/application.cpp
src/libsync/account.cpp

index 289717f4b220149d51825673541bb4b3e5d03d55..0ccbfbc7e2b974bb7ee6b3c01d9f1d74c0d9759f 100644 (file)
@@ -43,7 +43,9 @@ void AccountStateManager::setAccountState(AccountState *accountState)
         emit accountStateRemoved(_accountState);
     }
     _accountState = accountState;
-    emit accountStateAdded(accountState);
+    if (accountState) {
+        emit accountStateAdded(accountState);
+    }
 }
 
 void AccountStateManager::slotAccountAdded(AccountPtr account)
index 1e554cdcae767077e423734236ed84923fdbd4dd..946384ea1abe42b41f870fb8e0554de6865fe92b 100644 (file)
@@ -180,7 +180,8 @@ Application::Application(int &argc, char **argv) :
 
 Application::~Application()
 {
-    // qDebug() << "* OCC shutdown";
+    // Remove the account from the account manager so it can be deleted.
+    AccountManager::instance()->setAccount(AccountPtr());
 }
 
 void Application::slotLogin()
index 990b482d2b4687de936c556f94977e0e544f3029..14e3ad20208015a89d7d5513d5f49e5b2d195fa7 100644 (file)
@@ -63,7 +63,9 @@ void AccountManager::setAccount(AccountPtr account)
         emit accountRemoved(_account);
     }
     _account = account;
-    emit accountAdded(account);
+    if (account) {
+        emit accountAdded(account);
+    }
 }