Skip to content

Commit

Permalink
Fixed 11874 (leading 0s ignored by debugger)
Browse files Browse the repository at this point in the history
  • Loading branch information
nokturnusmf committed Nov 22, 2019
1 parent d660503 commit 5b6e7aa
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 6 deletions.
2 changes: 1 addition & 1 deletion Source/Core/DolphinQt/Debugger/MemoryViewWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -379,7 +379,7 @@ void MemoryViewWidget::OnCopyHex()
u64 value = accessors->ReadU64(addr);

QApplication::clipboard()->setText(
QStringLiteral("%1").arg(value, length * 2, 16, QLatin1Char('0')).left(length * 2));
QStringLiteral("%1").arg(value, sizeof(u64) * 2, 16, QLatin1Char('0')).left(length * 2));
}

void MemoryViewWidget::OnContextMenu()
Expand Down
13 changes: 8 additions & 5 deletions Source/Core/DolphinQt/Debugger/MemoryWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -488,28 +488,31 @@ void MemoryWidget::OnSetValue()
const QByteArray bytes = m_data_edit->text().toUtf8();

for (char c : bytes)
accessors->WriteU8(static_cast<u8>(c), addr++);
accessors->WriteU8(addr++, static_cast<u8>(c));
}
else
{
bool good_value;
u64 value = m_data_edit->text().toULongLong(&good_value, 16);
const QString text = m_data_edit->text();
const int length =
text.startsWith(QStringLiteral("0x"), Qt::CaseInsensitive) ? text.size() - 2 : text.size();
const u64 value = text.toULongLong(&good_value, 16);

if (!good_value)
{
ModalMessageBox::critical(this, tr("Error"), tr("Bad value provided."));
return;
}

if (value == static_cast<u8>(value))
if (length <= 2)
{
accessors->WriteU8(addr, static_cast<u8>(value));
}
else if (value == static_cast<u16>(value))
else if (length <= 4)
{
accessors->WriteU16(addr, static_cast<u16>(value));
}
else if (value == static_cast<u32>(value))
else if (length <= 8)
{
accessors->WriteU32(addr, static_cast<u32>(value));
}
Expand Down

0 comments on commit 5b6e7aa

Please sign in to comment.