From abc63e4432c2a1dc21bd1a490d08e923e6ee0ae0 Mon Sep 17 00:00:00 2001 From: Gingeh <39150378+Gingeh@users.noreply.github.com> Date: Fri, 3 Oct 2025 09:50:34 +1000 Subject: [PATCH] fix: warn before double-click toggling resource while game is running Closes #4119 Signed-off-by: Gingeh <39150378+Gingeh@users.noreply.github.com> --- .../minecraft/mod/ResourceFolderModel.cpp | 23 ++++++++++--------- .../pages/instance/ExternalResourcesPage.cpp | 10 -------- 2 files changed, 12 insertions(+), 21 deletions(-) diff --git a/launcher/minecraft/mod/ResourceFolderModel.cpp b/launcher/minecraft/mod/ResourceFolderModel.cpp index 2b4f9eb14..e8b4c862c 100644 --- a/launcher/minecraft/mod/ResourceFolderModel.cpp +++ b/launcher/minecraft/mod/ResourceFolderModel.cpp @@ -254,6 +254,18 @@ void ResourceFolderModel::deleteMetadata(const QModelIndexList& indexes) bool ResourceFolderModel::setResourceEnabled(const QModelIndexList& indexes, EnableAction action) { + if (m_instance != nullptr && m_instance->isRunning()) { + auto response = + CustomMessageBox::selectable(nullptr, tr("Confirm toggle"), + tr("If you enable/disable this resource while the game is running it may crash your game.\n" + "Are you sure you want to do this?"), + QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) + ->exec(); + + if (response != QMessageBox::Yes) + return false; + } + if (indexes.isEmpty()) return true; @@ -523,17 +535,6 @@ bool ResourceFolderModel::setData(const QModelIndex& index, [[maybe_unused]] con return false; if (role == Qt::CheckStateRole) { - if (m_instance != nullptr && m_instance->isRunning()) { - auto response = - CustomMessageBox::selectable(nullptr, tr("Confirm toggle"), - tr("If you enable/disable this resource while the game is running it may crash your game.\n" - "Are you sure you want to do this?"), - QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) - ->exec(); - - if (response != QMessageBox::Yes) - return false; - } return setResourceEnabled({ index }, EnableAction::TOGGLE); } diff --git a/launcher/ui/pages/instance/ExternalResourcesPage.cpp b/launcher/ui/pages/instance/ExternalResourcesPage.cpp index d0fb2347b..eba2ac1de 100644 --- a/launcher/ui/pages/instance/ExternalResourcesPage.cpp +++ b/launcher/ui/pages/instance/ExternalResourcesPage.cpp @@ -286,16 +286,6 @@ void ExternalResourcesPage::enableItem() void ExternalResourcesPage::disableItem() { - if (m_instance != nullptr && m_instance->isRunning()) { - auto response = CustomMessageBox::selectable(this, tr("Confirm disable"), - tr("If you disable this resource while the game is running it may crash your game.\n" - "Are you sure you want to do this?"), - QMessageBox::Warning, QMessageBox::Yes | QMessageBox::No, QMessageBox::No) - ->exec(); - - if (response != QMessageBox::Yes) - return; - } auto selection = m_filterModel->mapSelectionToSource(ui->treeView->selectionModel()->selection()); m_model->setResourceEnabled(selection.indexes(), EnableAction::DISABLE); }