/***************************************************************************
- * Copyright (C) 2005-2018 by the Quassel Project *
+ * Copyright (C) 2005-2020 by the Quassel Project *
* devel@quassel-irc.org *
* *
* This program is free software; you can redistribute it and/or modify *
* 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. *
***************************************************************************/
-#include "core.h"
#include "coreapplication.h"
-
-CoreApplication::CoreApplication(int &argc, char **argv)
+CoreApplication::CoreApplication(int& argc, char** argv)
: QCoreApplication(argc, argv)
{
-#ifdef Q_OS_MAC
- Quassel::disableCrashHandler();
-#endif /* Q_OS_MAC */
-
- Quassel::setRunMode(Quassel::CoreOnly);
+ Quassel::registerQuitHandler([this]() {
+ connect(_core.get(), &Core::shutdownComplete, this, &CoreApplication::onShutdownComplete);
+ _core->shutdown();
+ });
}
-
-CoreApplication::~CoreApplication()
+void CoreApplication::init()
{
- _core.reset();
+ _core = std::make_unique<Core>();
+ _core->init();
}
-
-void CoreApplication::init()
+void CoreApplication::onShutdownComplete()
{
- if (!Quassel::init()) {
- throw ExitException{EXIT_FAILURE, tr("Could not initialize Quassel!")};
- }
-
- _core.reset(new Core{}); // FIXME C++14: std::make_unique
- _core->init();
+ connect(_core.get(), &QObject::destroyed, QCoreApplication::instance(), &QCoreApplication::quit);
+ _core.release()->deleteLater();
}