New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixed #11874 (leading 0s ignored by debugger) #8479
Conversation
| @@ -493,23 +493,25 @@ void MemoryWidget::OnSetValue() | |||
| else | |||
| { | |||
| bool good_value; | |||
| u64 value = m_data_edit->text().toULongLong(&good_value, 16); | |||
| const auto& text = m_data_edit->text(); | |||
| int length = text.startsWith(QStringLiteral("0x")) ? text.size() - 2 : text.size(); | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What about uppercase 0X?
| @@ -493,23 +493,25 @@ void MemoryWidget::OnSetValue() | |||
| else | |||
| { | |||
| bool good_value; | |||
| u64 value = m_data_edit->text().toULongLong(&good_value, 16); | |||
| const auto& text = m_data_edit->text(); | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
text() returns a QString by value, so taking it by const reference, while valid, is somewhat visually misleading.
| @@ -493,23 +493,25 @@ void MemoryWidget::OnSetValue() | |||
| else | |||
| { | |||
| bool good_value; | |||
| u64 value = m_data_edit->text().toULongLong(&good_value, 16); | |||
| const auto& text = m_data_edit->text(); | |||
| int length = text.startsWith(QStringLiteral("0x")) ? text.size() - 2 : text.size(); | |||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and value can both be made const.
|
@CookiePLMonster Yep, complete oversight. @lioncash So it is, I'm not too familiar with Qt so just assumed. I additionally noticed and fixed a typo in the code for setting ASCII values, the arguments to WriteU8 were swapped. |
|
Looks good now, but please squash so those "PR feedback" commits disappear. |
Fixes both issues from the report.
For set value:
The original code converts the string into a value and then attempts to work out the size of the input by downcasting and comparing. This breaks for leading zeros as, for example, 0042 == (u8)0042. The fix calculates the correct length from the original string, taking into account the possibility that the string is prefixed by "0x".
For copy hex:
The code already attempts to take the first "length" characters, however incorrectly converts/pads the value and so copies the first "length" nonzero characters. This meant that copying the 01 of 01 23 would result in the string 12 being copied. The fix always fully pads the read value and then correctly takes the leftmost characters.