summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorAdmiral H. Curtiss <pikachu025@gmail.com>2025-07-01 22:54:37 +0200
committerGitHub <noreply@github.com>2025-07-01 22:54:37 +0200
commita84fa387de6e812578b98d9cfbbcd0b7644640d1 (patch)
treeda390ff3484ff06d1ee193b3add1d7e434faede2 /Source/Core
parent74eeeebfdee44f6921afdc3014d27c928b5737e1 (diff)
parent0093ed1ac895b82279d7aa9422e7f2a94d192a21 (diff)
Merge pull request #13785 from Dentomologist/memorywidget_fix_hex_input_validation_errors
MemoryWidget: Fix hex input validation errors
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/DolphinQt/Debugger/MemoryWidget.cpp20
1 files changed, 17 insertions, 3 deletions
diff --git a/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp b/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp
index 4c15e92a03..b4ef33fbe5 100644
--- a/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp
+++ b/Source/Core/DolphinQt/Debugger/MemoryWidget.cpp
@@ -618,12 +618,26 @@ 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.
if (input_text.startsWith(QLatin1Char('-')))
- input_text.insert(1, QStringLiteral("0x"));
- else
+ {
+ if (!input_text.startsWith(QStringLiteral("-0x"), Qt::CaseInsensitive))
+ input_text.insert(1, QStringLiteral("0x"));
+ }
+ else if (!input_text.startsWith(QStringLiteral("0x"), Qt::CaseInsensitive))
+ {
input_text.prepend(QStringLiteral("0x"));
+ }
}
QFont font;