Skip to content

Commit

Permalink
Merge pull request #405 from Alphalaneous/Crash-Fix
Browse files Browse the repository at this point in the history
Fix crash if EditButtonBar is empty
  • Loading branch information
HJfod authored Aug 18, 2024
2 parents 3af349a + 3026f2b commit ca9064d
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions src/features/scaling/EditorUIScaling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -160,9 +160,11 @@ class $modify(ScaledUI, EditorUI) {
auto winSize = CCDirector::get()->getWinSize();
for (auto c : CCArrayExt<CCNode*>(this->getChildren())) {
if (auto bar = typeinfo_cast<EditButtonBar*>(c)) {
getChild(bar, 0)->setPositionX(-winSize.width / 2 + 5);
if (auto menu = getChildOfType<CCMenu>(bar, 0)) {
menu->setPositionX(winSize.width / 2 + 5);
if (bar->getChildrenCount() > 0) {
getChild(bar, 0)->setPositionX(-winSize.width / 2 + 5);
if (auto menu = getChildOfType<CCMenu>(bar, 0)) {
menu->setPositionX(winSize.width / 2 + 5);
}
}
bar->setPositionX(winSize.width / 2);
}
Expand Down

0 comments on commit ca9064d

Please sign in to comment.