#include "client.h"
#include "core.h"
#include "internalpeer.h"
+#include "logmessage.h"
#include "qtui.h"
class InternalPeer;
MonolithicApplication::MonolithicApplication(int &argc, char **argv)
: QtUiApplication(argc, argv)
{
-#if defined(HAVE_KDE4) || defined(Q_OS_MAC)
- Quassel::disableCrashHandler();
-#endif /* HAVE_KDE4 || Q_OS_MAC */
-
Quassel::setRunMode(Quassel::Monolithic);
}
}
-MonolithicApplication::~MonolithicApplication()
+Quassel::QuitHandler MonolithicApplication::quitHandler()
+{
+ return [this]() {
+ quInfo() << "Client shutting down...";
+ connect(_client.get(), SIGNAL(destroyed()), this, SLOT(onClientDestroyed()));
+ _client.release()->deleteLater();
+ };
+}
+
+
+void MonolithicApplication::onClientDestroyed()
{
- // Client needs to be destroyed first
- Client::destroy();
- _coreThread.quit();
- _coreThread.wait();
- Quassel::destroy();
+ if (_core) {
+ connect(_core, SIGNAL(shutdownComplete()), this, SLOT(onCoreShutdown()));
+ _core->shutdown();
+ }
+ else {
+ QCoreApplication::quit();
+ }
+}
+
+
+void MonolithicApplication::onCoreShutdown()
+{
+ if (_core) {
+ connect(_core, SIGNAL(destroyed()), QCoreApplication::instance(), SLOT(quit()));
+ _coreThread.quit();
+ _coreThread.wait();
+ }
+ else {
+ QCoreApplication::quit();
+ }
}