Fix patches not save changes properly (#1493)
Some checks are pending
Build and Release / reuse (push) Waiting to run
Build and Release / clang-format (push) Waiting to run
Build and Release / get-info (push) Waiting to run
Build and Release / windows-sdl (push) Blocked by required conditions
Build and Release / windows-qt (push) Blocked by required conditions
Build and Release / macos-sdl (push) Blocked by required conditions
Build and Release / macos-qt (push) Blocked by required conditions
Build and Release / linux-sdl (push) Blocked by required conditions
Build and Release / linux-qt (push) Blocked by required conditions
Build and Release / pre-release (push) Blocked by required conditions

Don't use ```QCheckBox::text()``` because it may return strings that contain "&" cause patch name comparison to fail.
This commit is contained in:
Quang Ngô 2024-11-07 03:44:22 +07:00 committed by GitHub
parent 46ac48c311
commit f45cad6bc9
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -434,7 +434,9 @@ QCheckBox* CheatsPatches::findCheckBoxByName(const QString& name) {
QWidget* widget = item->widget(); QWidget* widget = item->widget();
QCheckBox* checkBox = qobject_cast<QCheckBox*>(widget); QCheckBox* checkBox = qobject_cast<QCheckBox*>(widget);
if (checkBox) { 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; return checkBox;
} }
} }
@ -1176,6 +1178,7 @@ void CheatsPatches::addPatchesToLayout(const QString& filePath) {
if (!patchName.isEmpty() && !patchLines.isEmpty()) { if (!patchName.isEmpty() && !patchLines.isEmpty()) {
QCheckBox* patchCheckBox = new QCheckBox(patchName); QCheckBox* patchCheckBox = new QCheckBox(patchName);
patchCheckBox->setProperty("patchName", patchName);
patchCheckBox->setChecked(isEnabled); patchCheckBox->setChecked(isEnabled);
patchesGroupBoxLayout->addWidget(patchCheckBox); patchesGroupBoxLayout->addWidget(patchCheckBox);
@ -1349,8 +1352,10 @@ bool CheatsPatches::eventFilter(QObject* obj, QEvent* event) {
void CheatsPatches::onPatchCheckBoxHovered(QCheckBox* checkBox, bool hovered) { void CheatsPatches::onPatchCheckBoxHovered(QCheckBox* checkBox, bool hovered) {
if (hovered) { if (hovered) {
QString text = checkBox->text(); const auto patchName = checkBox->property("patchName");
updateNoteTextEdit(text); if (patchName.isValid()) {
updateNoteTextEdit(patchName.toString());
}
} else { } else {
instructionsTextEdit->setText(defaultTextEdit); instructionsTextEdit->setText(defaultTextEdit);
} }