Skip to content
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

Merged
merged 1 commit into from Nov 27, 2019
Merged

Fixed #11874 (leading 0s ignored by debugger) #8479

merged 1 commit into from Nov 27, 2019

Conversation

nokturnusmf
Copy link
Contributor

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.

@@ -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();
Copy link
Contributor

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();
Copy link
Member

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();
Copy link
Member

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.

@nokturnusmf
Copy link
Contributor Author

@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.

@CookiePLMonster
Copy link
Contributor

Looks good now, but please squash so those "PR feedback" commits disappear.

@Helios747 Helios747 merged commit 66ca83e into dolphin-emu:master Nov 27, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
4 participants