From 6ab8fccc603b838d51b7b2df3a7bb84377b2b91d Mon Sep 17 00:00:00 2001 From: nordsoft Date: Thu, 17 Nov 2022 05:06:23 +0400 Subject: [PATCH] Fix crash --- launcher/lobby/lobby_moc.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/launcher/lobby/lobby_moc.cpp b/launcher/lobby/lobby_moc.cpp index 8a3df3685..fa6c8586b 100644 --- a/launcher/lobby/lobby_moc.cpp +++ b/launcher/lobby/lobby_moc.cpp @@ -31,7 +31,11 @@ Lobby::~Lobby() QMap Lobby::buildModsMap() const { QMap result; - const auto & modlist = qobject_cast(qApp->activeWindow())->getModList(); + QObject * mainWindow = qApp->activeWindow(); + while(mainWindow->parent()) + mainWindow = mainWindow->parent(); + const auto & modlist = qobject_cast(mainWindow)->getModList(); + for(auto & modname : modlist.getModList()) { auto mod = modlist.getMod(modname); @@ -45,7 +49,11 @@ QMap Lobby::buildModsMap() const bool Lobby::isModAvailable(const QString & modName, const QString & modVersion) const { - const auto & modlist = qobject_cast(qApp->activeWindow())->getModList(); + QObject * mainWindow = qApp->activeWindow(); + while(mainWindow->parent()) + mainWindow = mainWindow->parent(); + const auto & modlist = qobject_cast(mainWindow)->getModList(); + if(!modlist.hasMod(modName)) return false;