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
Debugger MemoryViewWidget: Allow direct editing of memory cells. #10794
Debugger MemoryViewWidget: Allow direct editing of memory cells. #10794
Conversation
Oh, nice. But yes I agree, the text field and the explicit cell editing probably want to share the parsing code, just so that you don't have weird edge cases where typing a value works in the text box but not in the cell or something. |
@AdmiralCurtiss Any thoughts on where the parsing code should go and what should call it? MemoryViewWidget doesn't currently send any data to MemoryWidget. Should it be in MemoryView? Should it return a QString or a QByteArray? MemoryWidget uses it as a QString right now, but MemoryViewWidget would only need the QByteArray. |
I'd put it in |
@AdmiralCurtiss I don't know how to form a correct length QByteArray without first making a padded QString ( u16 1 -> 0001). Is it okay to use the MemoryWidget logic then just tack on a QByteArray conversion at the end? |
Do you need a QByteArray? You can just do something like |
@AdmiralCurtiss Ok that works, but I'm not experienced with std::array. How do I properly return the array from the function when the size is variable? |
|
cecfd19
to
b261f2e
Compare
Thanks, it worked great! Not sure if I'm sharing the enum correctly. |
if (m_updating == true) | ||
return; |
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.
Instead of having this flag, it might be better to use the either QSignalBlocker
or the signal blocking helper from DolphinQt/QtUtils/SignalBlocking.h
?
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 seems to work fine. I was getting a stack overflow when having no updating check or signal block. Is one QSignalBlocker placed in this spot good?
if (accessors->IsValidAddress(address) && !bytes.empty()) | ||
{ | ||
for (const u8 c : bytes) | ||
accessors->WriteU8(address++, c); | ||
} |
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.
You need to re-verify the address for each byte, you could write past the end of memory.
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.
Interesting. I accidentally carried the check over from loading memory values. In the current memory widget coding, there's no check at all. I'm not sure how it handles input that starts in range then goes out of range.
I don't think I need the check at all. You can only edit a cell if it is a valid address, and you can only go past the cell size if you input ascii. but I'm not sure if that should be allowed?
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.
Ok so I stepped through it in the VS debugger. It does kind of seem to freak out. I added an end address check, plus added address checks to MemoryWidget. I don't think we want to write anything if the end address is invalid.
|
||
bytes = m_view->ConvertTextToBytes(type, text); | ||
|
||
// Cannot be used while update is running. |
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 is this comment trying to say here?
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.
I was just noting this caused a stack overflow with Update().
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.
Yeah, but what is it referring to? The OnItemChanged()
function? Then it should be on top of that, not in the middle of it.
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.
I think I can just remove the note now. The accessor itself was crashing with the accessor in Update() I think? When I deleted the accessor stuff, it was fine, so I was marking that specifically.
b261f2e
to
ea2500c
Compare
You broke something with the padding in the preview box, eg: e: here: #10794 (comment) |
ea2500c
to
cae5b6a
Compare
I don't 100% understand the accessor stuff. Does checking for a valid address work for all address spaces? Does setting values even work for other address spaces besides effective? |
It should. Can you find a situation where it doesn't? |
No, it looks good. I just never use the other address space options, so wasn't sure if I'd break something I don't use. I was able to give it a quick test and it worked. |
c411962
to
9768506
Compare
9768506
to
bd59b0a
Compare
It seems to work fine, but not really happy with how I coded it. It seems like MemoryView and Memory widget should share the same update functions, but I wasn't sure how to responsibly put that together.
Was anyone else working on this? Thought I'd PR it to open a discussion.