1
0
mirror of https://gitlab.com/kelteseth/ScreenPlay.git synced 2024-11-22 02:32:29 +01:00

Fix crash on exit

This commit is contained in:
Elias Steurer 2023-10-29 18:26:01 +01:00
parent 23873e1f1f
commit d044963d50
3 changed files with 11 additions and 6 deletions

View File

@ -104,7 +104,6 @@ public slots:
private:
QNetworkAccessManager m_networkAccessManager;
QElapsedTimer m_continuousIntegrationMetricsTimer;
std::unique_ptr<QQmlApplicationEngine> m_mainWindowEngine;
std::unique_ptr<Create> m_create;

View File

@ -67,8 +67,6 @@ App::App()
: QObject(nullptr)
{
m_continuousIntegrationMetricsTimer.start();
QGuiApplication::setWindowIcon(QIcon(":/qml/ScreenPlayApp/assets/icons/app.ico"));
QGuiApplication::setOrganizationName("ScreenPlay");
QGuiApplication::setOrganizationDomain("screen-play.app");
@ -221,8 +219,17 @@ void App::exit()
{
m_screenPlayManager->removeAllWallpapers();
m_screenPlayManager->removeAllWidgets();
auto* guiAppInst = dynamic_cast<QGuiApplication*>(QGuiApplication::instance());
guiAppInst->quit();
// Must be called inside a separate event loop otherwise we
// would kill the qml engine while it is calling this function.
// A single shot timer is a handy woraround for this.
QTimer::singleShot(0, this, [this]() {
auto* appInst = QGuiApplication::instance();
// We must ensure that we kill the qml engine first
// before we destory the rest of the app
m_mainWindowEngine->clearSingletons();
m_mainWindowEngine.reset();
appInst->quit();
});
}
void App::showDockIcon(const bool show)

View File

@ -96,7 +96,6 @@ int main(int argc, char* argv[])
MacUtils::showDockIcon(false);
#endif
logging = std::make_unique<const ScreenPlayUtil::LoggingHandler>("ScreenPlayWidget_"+ appID);
const int status = app.exec();
logging.reset();
return status;