Qt: Fix menu creation from incorrect thread

This commit is contained in:
Stenzek 2024-10-19 17:05:17 +10:00
parent 43ed92415d
commit c279376cff
No known key found for this signature in database
1 changed files with 8 additions and 8 deletions

View File

@ -1015,22 +1015,22 @@ void MainWindow::populateCheatsMenu(QMenu* menu)
if (!System::IsValid())
return;
if (!Cheats::AreCheatsEnabled())
{
QAction* action = menu->addAction(tr("Cheats are not enabled."));
action->setEnabled(false);
return;
}
QStringList names;
Cheats::EnumerateManualCodes([&names](const std::string& name) {
names.append(QString::fromStdString(name));
return true;
});
if (names.empty())
if (Cheats::AreCheatsEnabled() && names.empty())
return;
QtHost::RunOnUIThread([menu, names = std::move(names)]() {
if (names.empty())
{
QAction* action = menu->addAction(tr("Cheats are not enabled."));
action->setEnabled(false);
return;
}
QMenu* apply_submenu = menu->addMenu(tr("&Apply Cheat"));
for (const QString& name : names)
{