Fix actionVisitItemPage insersion, and prevent widebar segfault

Signed-off-by: TheKodeToad <TheKodeToad@proton.me>
This commit is contained in:
TheKodeToad 2023-07-08 20:51:27 +01:00
parent 67d473aab7
commit 08c140b9b4
2 changed files with 12 additions and 3 deletions

View File

@ -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] {

View File

@ -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;
}