Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix crash when editing instance and prevent similar crashes in future #1332

Merged
merged 1 commit into from
Jul 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion launcher/ui/pages/instance/ModFolderPage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ ModFolderPage::ModFolderPage(BaseInstance* inst, std::shared_ptr<ModFolderModel>
connect(ui->actionUpdateItem, &QAction::triggered, this, &ModFolderPage::updateMods);

ui->actionVisitItemPage->setToolTip(tr("Go to mod's home page"));
ui->actionsToolbar->insertActionAfter(ui->actionViewFolder, ui->actionVisitItemPage);
ui->actionsToolbar->addAction(ui->actionVisitItemPage);
connect(ui->actionVisitItemPage, &QAction::triggered, this, &ModFolderPage::visitModPages);

auto check_allow_update = [this] {
Expand Down
13 changes: 11 additions & 2 deletions launcher/ui/widgets/WideBar.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -116,12 +116,21 @@ void WideBar::insertActionAfter(QAction* after, QAction* action)
if (iter == m_entries.end())
return;

iter++;
// the action to insert after is present
// however, the element after it isn't valid
if (iter == m_entries.end()) {
// append the action instead of inserting it
addAction(action);
return;
}

BarEntry entry;
entry.bar_action = insertWidget((iter + 1)->bar_action, new ActionButton(action, this, m_use_default_action));
entry.bar_action = insertWidget(iter->bar_action, new ActionButton(action, this, m_use_default_action));
entry.menu_action = action;
entry.type = BarEntry::Type::Action;

m_entries.insert(iter + 1, entry);
m_entries.insert(iter, entry);

m_menu_state = MenuState::Dirty;
}
Expand Down