diff --git a/src/kmkernel.cpp b/src/kmkernel.cpp --- a/src/kmkernel.cpp +++ b/src/kmkernel.cpp @@ -1074,33 +1074,14 @@ void KMKernel::closeAllKMailWindows() { - QList windowsToDelete; - foreach (KMainWindow *window, KMainWindow::memberList()) { if (::qobject_cast(window) || ::qobject_cast(window)) { // close and delete the window window->setAttribute(Qt::WA_DeleteOnClose); window->close(); - windowsToDelete.append(window); } } - - // We delete all main windows here. Above we called close(), but that calls - // deleteLater() internally, therefore does not delete it immediately. - // This would lead to problems when closing Kontact when a composer window - // is open, because the destruction order is: - // - // 1. destructor of the Kontact mainwinow - // 2. delete all parts - // 3. the KMail part destructor calls KMKernel::cleanup(), which calls - // this function - // 4. delete all other mainwindows - // - // Deleting the composer windows here will make sure that step 4 will not delete - // any composer window, which would fail because the kernel is already deleted. - qDeleteAll(windowsToDelete); - windowsToDelete.clear(); } void KMKernel::cleanup(void) diff --git a/src/main.cpp b/src/main.cpp --- a/src/main.cpp +++ b/src/main.cpp @@ -137,17 +137,19 @@ // import i18n data and icons from libraries: KMail::insertLibraryIcons(); - //local, do the init - KMKernel kmailKernel; - kmailKernel.init(); + // do not make local objects that interacts on DBus + QPointer kmailKernel = new KMKernel; + + // do the init + kmailKernel->init(); // and session management - kmailKernel.doSessionManagement(); + kmailKernel->doSessionManagement(); // any dead letters? - kmailKernel.recoverDeadLetters(); + kmailKernel->recoverDeadLetters(); - kmkernel->setupDBus(); // Ok. We are ready for D-Bus requests. + kmailKernel->setupDBus(); // Ok. We are ready for D-Bus requests. //If the instance hasn't been created yet, do that now app.setEventLoopReached(); @@ -155,7 +157,10 @@ // Go! int ret = qApp->exec(); - // clean up - kmailKernel.cleanup(); + if (kmailKernel) { + // clean up + kmailKernel->cleanup(); + delete kmkernel; + } return ret; }