From 242bce27a1a1bd000e5c0e5e063be431092169ec Mon Sep 17 00:00:00 2001 From: sowens99 Date: Mon, 27 Sep 2021 14:28:08 -0400 Subject: [PATCH 1/2] Do not accept on hotkey syntax errors Previously you could type whatever gibberish you wanted into the formula bar, press OK, and receive a modal syntax error window. Closing the syntax error window would cause the hotkey config window to close as well, and your gibberish would be applied to the hotkey assignment. This commit requires that a syntax error does not occur before accept() is called. --- Source/Core/DolphinQt/Config/Mapping/IOWindow.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/Source/Core/DolphinQt/Config/Mapping/IOWindow.cpp b/Source/Core/DolphinQt/Config/Mapping/IOWindow.cpp index 0deb4f5293..9f3c596463 100644 --- a/Source/Core/DolphinQt/Config/Mapping/IOWindow.cpp +++ b/Source/Core/DolphinQt/Config/Mapping/IOWindow.cpp @@ -515,9 +515,11 @@ void IOWindow::OnDialogButtonPressed(QAbstractButton* button) { ModalMessageBox::warning(this, tr("Error"), tr("The expression contains a syntax error.")); } - - // must be the OK button - accept(); + else + { + // must be the OK button + accept(); + } } void IOWindow::OnDetectButtonPressed() From 556323561c3fe3449899e9f549da1d6d50022cee Mon Sep 17 00:00:00 2001 From: sowens99 Date: Mon, 27 Sep 2021 14:29:34 -0400 Subject: [PATCH 2/2] Do not update hotkey assignments on window close If this commit is not applied, then the previous commit will cause hotkeys to be saved if there is a syntax error when hitting "OK" and the user presses the X to close the window. This commit only applies changes to hotkey config if no syntax error occurs. --- Source/Core/DolphinQt/Config/Mapping/IOWindow.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Source/Core/DolphinQt/Config/Mapping/IOWindow.cpp b/Source/Core/DolphinQt/Config/Mapping/IOWindow.cpp index 9f3c596463..659b6a889f 100644 --- a/Source/Core/DolphinQt/Config/Mapping/IOWindow.cpp +++ b/Source/Core/DolphinQt/Config/Mapping/IOWindow.cpp @@ -509,7 +509,6 @@ void IOWindow::OnDialogButtonPressed(QAbstractButton* button) const auto lock = ControllerEmu::EmulatedController::GetStateLock(); UpdateExpression(m_expression_text->toPlainText().toStdString()); - m_original_expression = m_reference->GetExpression(); if (ciface::ExpressionParser::ParseStatus::SyntaxError == m_reference->GetParseStatus()) { @@ -518,6 +517,7 @@ void IOWindow::OnDialogButtonPressed(QAbstractButton* button) else { // must be the OK button + m_original_expression = m_reference->GetExpression(); accept(); } }