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

#3280: Selection shifts when MemoryMap is updated #3291

Open
wants to merge 1 commit into
base: development
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 15 additions & 1 deletion src/gui/Src/Gui/MemoryMapView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -431,8 +431,10 @@ void MemoryMapView::refreshMapSlot()
MEMMAP memoryMap = {};
DbgMemMap(&memoryMap);

setRowCount(memoryMap.count);
duint currSelectedAddressRow = (duint)getCellUserdata(getInitialSelection(), ColAddress);
bool oldAddressFound = false;

setRowCount(memoryMap.count);
auto strUser = tr("User");
auto strSystem = tr("System");

Expand All @@ -444,6 +446,11 @@ void MemoryMapView::refreshMapSlot()
setCellContent(i, ColAddress, ToPtrString((duint)mbi.BaseAddress));
setCellUserdata(i, ColAddress, (duint)mbi.BaseAddress);

if((duint)mbi.BaseAddress == currSelectedAddressRow)
{
oldAddressFound = true;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think it's necessary to delay setting the selection and storing the state. You can directly call setSingleSelection here to simplify everything. Also the variable name is no longer accurate, it should be something like prevSelectedBase

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the reloadData function below caused some problems with setSingleSelection (it was jumping around like crazy)

currSelectedAddressRow = i;
}
// Size
setCellContent(i, ColSize, ToPtrString((duint)mbi.RegionSize));
setCellUserdata(i, ColSize, (duint)mbi.RegionSize);
Expand Down Expand Up @@ -527,6 +534,13 @@ void MemoryMapView::refreshMapSlot()
if(memoryMap.page != 0)
BridgeFree(memoryMap.page);
reloadData(); //refresh memory map

if(oldAddressFound && currSelectedAddressRow != prevSelectedRow)
{
setSingleSelection(currSelectedAddressRow);
prevSelectedRow = currSelectedAddressRow;
}

}

void MemoryMapView::stateChangedSlot(DBGSTATE state)
Expand Down
1 change: 1 addition & 0 deletions src/gui/Src/Gui/MemoryMapView.h
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,5 @@ public slots:
QMenu* mPluginMenu;

duint mCipBase;
int prevSelectedRow;
};