From 37dd6c287eac591b4d97cbfd90d16c2093b68020 Mon Sep 17 00:00:00 2001 From: Dentomologist Date: Thu, 9 Jul 2026 21:11:43 -0700 Subject: ResourcePackManager: Fix crash when removing pack Avoid accessing destroyed `QTableWidgetItem` by retrieving the desired path from the item before it's destroyed. In `ResourcePackManager::Remove` pointers to the selected items in `m_table_widget` were saved in the local variable `items` before calling `Uninstall`. `Uninstall` called `RepopulateTable` which called `m_table_widget->clear()`, destroying the table's descendants. Upon returning to `Remove` `items` then pointed to some of those destroyed descendants, and passing `items[0]` to `GetResourcePackIndex` resulted in a call to `item->row()` which was a use-after-free. Fixes https://bugs.dolphin-emu.org/issues/14095. --- Source/Core/DolphinQt/ResourcePackManager.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) (limited to 'Source') diff --git a/Source/Core/DolphinQt/ResourcePackManager.cpp b/Source/Core/DolphinQt/ResourcePackManager.cpp index 90739da45f..221a752f57 100644 --- a/Source/Core/DolphinQt/ResourcePackManager.cpp +++ b/Source/Core/DolphinQt/ResourcePackManager.cpp @@ -3,6 +3,8 @@ #include "DolphinQt/ResourcePackManager.h" +#include + #include #include #include @@ -243,8 +245,10 @@ void ResourcePackManager::Remove() if (box.exec() != QMessageBox::Yes) return; + const std::string selected_pack_path = + ResourcePack::GetPacks()[GetResourcePackIndex(items[0])].GetPath(); Uninstall(); - File::Delete(ResourcePack::GetPacks()[GetResourcePackIndex(items[0])].GetPath()); + File::Delete(selected_pack_path); RepopulateTable(); } -- cgit v1.2.3 From a18fd2d21b82f33c5ec603d0a76e136db0e30a4c Mon Sep 17 00:00:00 2001 From: Dentomologist Date: Fri, 10 Jul 2026 19:51:06 -0700 Subject: ResourcePackManager: Erase Removed pack from list and table Erase a removed pack from ResourcePack::::packs instead of only deleting the pack file from the disk. This causes the repopulated table to actually display that the pack has been removed (which previously only happened after restarting Dolphin or hitting `Refresh`), and also removes the pack from the `Packs.ini` file. --- Source/Core/DolphinQt/ResourcePackManager.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'Source') diff --git a/Source/Core/DolphinQt/ResourcePackManager.cpp b/Source/Core/DolphinQt/ResourcePackManager.cpp index 221a752f57..c342b29bae 100644 --- a/Source/Core/DolphinQt/ResourcePackManager.cpp +++ b/Source/Core/DolphinQt/ResourcePackManager.cpp @@ -17,6 +17,7 @@ #include "DolphinQt/QtUtils/ModalMessageBox.h" #include "DolphinQt/QtUtils/NonDefaultQPushButton.h" #include "UICommon/ResourcePack/Manager.h" +#include "UICommon/ResourcePack/ResourcePack.h" ResourcePackManager::ResourcePackManager(QWidget* widget) : QDialog(widget) { @@ -245,9 +246,11 @@ void ResourcePackManager::Remove() if (box.exec() != QMessageBox::Yes) return; - const std::string selected_pack_path = - ResourcePack::GetPacks()[GetResourcePackIndex(items[0])].GetPath(); + ResourcePack::ResourcePack& selected_pack = + ResourcePack::GetPacks()[GetResourcePackIndex(items[0])]; + const std::string selected_pack_path = selected_pack.GetPath(); Uninstall(); + ResourcePack::Remove(selected_pack); File::Delete(selected_pack_path); RepopulateTable(); } -- cgit v1.2.3