From f45cad6bc970d97f5a2b00913f8014a5ef08aeb3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Quang=20Ng=C3=B4?= Date: Thu, 7 Nov 2024 03:44:22 +0700 Subject: [PATCH] Fix patches not save changes properly (#1493) Don't use ```QCheckBox::text()``` because it may return strings that contain "&" cause patch name comparison to fail. --- src/qt_gui/cheats_patches.cpp | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/qt_gui/cheats_patches.cpp b/src/qt_gui/cheats_patches.cpp index 6e2e4f20..a35136f1 100644 --- a/src/qt_gui/cheats_patches.cpp +++ b/src/qt_gui/cheats_patches.cpp @@ -434,7 +434,9 @@ QCheckBox* CheatsPatches::findCheckBoxByName(const QString& name) { QWidget* widget = item->widget(); QCheckBox* checkBox = qobject_cast(widget); if (checkBox) { - if (checkBox->text().toStdString().find(name.toStdString()) != std::string::npos) { + const auto patchName = checkBox->property("patchName"); + if (patchName.isValid() && patchName.toString().toStdString().find( + name.toStdString()) != std::string::npos) { return checkBox; } } @@ -1176,6 +1178,7 @@ void CheatsPatches::addPatchesToLayout(const QString& filePath) { if (!patchName.isEmpty() && !patchLines.isEmpty()) { QCheckBox* patchCheckBox = new QCheckBox(patchName); + patchCheckBox->setProperty("patchName", patchName); patchCheckBox->setChecked(isEnabled); patchesGroupBoxLayout->addWidget(patchCheckBox); @@ -1349,8 +1352,10 @@ bool CheatsPatches::eventFilter(QObject* obj, QEvent* event) { void CheatsPatches::onPatchCheckBoxHovered(QCheckBox* checkBox, bool hovered) { if (hovered) { - QString text = checkBox->text(); - updateNoteTextEdit(text); + const auto patchName = checkBox->property("patchName"); + if (patchName.isValid()) { + updateNoteTextEdit(patchName.toString()); + } } else { instructionsTextEdit->setText(defaultTextEdit); }