From 0093ed1ac895b82279d7aa9422e7f2a94d192a21 Mon Sep 17 00:00:00 2001 From: Dentomologist Date: Mon, 30 Jun 2025 00:05:44 -0700 Subject: [PATCH] MemoryWidget: Fix "Hex Byte String" validation failures Fix the input string failing to validate when the "Hex Byte String" input type is selected and either the user adds a 0x prefix or the "Hex" box is checked (or both). The latter failure was particularly troublesome because when "Hex Byte String" is selected the "Hex" checkbox is disabled. Users would have to switch to a data type that enabled the box, toggle it, then switch back to "Hex Byte String" to fix it. Fix these errors by not adding a prefix when the "Hex" box is checked, and removing the "0x" prefix from the user's input if present. --- Source/Core/DolphinQt/Debugger/MemoryWidget.cpp | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp b/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp index 0b0363049c..b4ef33fbe5 100644 --- a/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp +++ b/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp @@ -618,7 +618,14 @@ void MemoryWidget::ValidateAndPreviewInputValue() if (input_type != Type::ASCII) input_text.remove(QLatin1Char(' ')); - if (m_base_check->isChecked()) + if (input_type == Type::HexString) + { + // Hex strings are parsed using QByteArray::fromHex which doesn't expect a 0x prefix. If the + // user has inserted one, remove it. + if (input_text.startsWith(QStringLiteral("0x"), Qt::CaseInsensitive)) + input_text.remove(0, 2); + } + else if (m_base_check->isChecked()) { // Add 0x to the front of the input (after the '-', if present), but only if the user didn't // already do so.