1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-12-24 22:14:36 +02:00

Fix crash

This commit is contained in:
nordsoft 2022-11-17 05:06:23 +04:00
parent ddebf85665
commit 6ab8fccc60

View File

@ -31,7 +31,11 @@ Lobby::~Lobby()
QMap<QString, QString> Lobby::buildModsMap() const
{
QMap<QString, QString> result;
const auto & modlist = qobject_cast<MainWindow*>(qApp->activeWindow())->getModList();
QObject * mainWindow = qApp->activeWindow();
while(mainWindow->parent())
mainWindow = mainWindow->parent();
const auto & modlist = qobject_cast<MainWindow*>(mainWindow)->getModList();
for(auto & modname : modlist.getModList())
{
auto mod = modlist.getMod(modname);
@ -45,7 +49,11 @@ QMap<QString, QString> Lobby::buildModsMap() const
bool Lobby::isModAvailable(const QString & modName, const QString & modVersion) const
{
const auto & modlist = qobject_cast<MainWindow*>(qApp->activeWindow())->getModList();
QObject * mainWindow = qApp->activeWindow();
while(mainWindow->parent())
mainWindow = mainWindow->parent();
const auto & modlist = qobject_cast<MainWindow*>(mainWindow)->getModList();
if(!modlist.hasMod(modName))
return false;