Skip to content

Commit

Permalink
detect entity memory size
Browse files Browse the repository at this point in the history
  • Loading branch information
Mr-Auto committed Mar 27, 2024
1 parent 23a31f4 commit 108dfc0
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 7 deletions.
8 changes: 5 additions & 3 deletions include/Views/ViewEntity.h
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ namespace S2Plugin
QWidget* mTabLevel;
QWidget* mTabCPP;

uintptr_t mEntityPtr;
uintptr_t mComparisonEntityPtr{0};
size_t mEntitySize{0};
ViewToolbar* mToolbar;

// TOP LAYOUT
QPushButton* mRefreshButton;
QCheckBox* mAutoRefreshCheckBox;
Expand All @@ -72,9 +77,6 @@ namespace S2Plugin
// TAB CPP
QTextEdit* mCPPTextEdit;
CPPSyntaxHighlighter* mCPPSyntaxHighlighter;
uintptr_t mEntityPtr;
uintptr_t mComparisonEntityPtr{0};
ViewToolbar* mToolbar;

void initializeUI();
void updateMemoryViewOffsetAndSize();
Expand Down
12 changes: 8 additions & 4 deletions src/Views/ViewEntity.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,18 +294,22 @@ void S2Plugin::ViewEntity::interpretAsChanged(const QString& classType)
recursiveHighlight(*it + ".", config->typeFieldsOfEntitySubclass(*it), recursiveHighlight);
}

// updateMemoryViewOffsetAndSize();
// mInterpretAsComboBox->setCurrentText("");
mMainTreeView->updateTree(0, 0, true);
mEntitySize = delta;
updateMemoryViewOffsetAndSize();
}
}

void S2Plugin::ViewEntity::updateMemoryViewOffsetAndSize()
{
static const size_t defaultBytesShown = 0x188; // big bucket size, small bucket size: 0xD0
constexpr size_t smallEntityBucket = 0xD0;
constexpr size_t bigEntityBucket = 0x188;

mMemoryView->setOffsetAndSize(mEntityPtr, defaultBytesShown);
mMemoryComparisonView->setOffsetAndSize(mComparisonEntityPtr, defaultBytesShown);
size_t bytesShown = mEntitySize > smallEntityBucket ? bigEntityBucket : smallEntityBucket;

mMemoryView->setOffsetAndSize(mEntityPtr, bytesShown);
mMemoryComparisonView->setOffsetAndSize(mComparisonEntityPtr, bytesShown);
}

void S2Plugin::ViewEntity::updateComparedMemoryViewHighlights()
Expand Down

0 comments on commit 108dfc0

Please sign in to comment.