From 3026f2ba440d61989237f1fca0c5845f03aef78b Mon Sep 17 00:00:00 2001 From: Alphalaneous <38200084+Alphalaneous@users.noreply.github.com> Date: Sun, 18 Aug 2024 16:20:26 -0400 Subject: [PATCH] Fix crash if EditButtonBar is empty --- src/features/scaling/EditorUIScaling.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/features/scaling/EditorUIScaling.cpp b/src/features/scaling/EditorUIScaling.cpp index 3d5de91..b3d0e8e 100644 --- a/src/features/scaling/EditorUIScaling.cpp +++ b/src/features/scaling/EditorUIScaling.cpp @@ -160,9 +160,11 @@ class $modify(ScaledUI, EditorUI) { auto winSize = CCDirector::get()->getWinSize(); for (auto c : CCArrayExt(this->getChildren())) { if (auto bar = typeinfo_cast(c)) { - getChild(bar, 0)->setPositionX(-winSize.width / 2 + 5); - if (auto menu = getChildOfType(bar, 0)) { - menu->setPositionX(winSize.width / 2 + 5); + if (bar->getChildrenCount() > 0) { + getChild(bar, 0)->setPositionX(-winSize.width / 2 + 5); + if (auto menu = getChildOfType(bar, 0)) { + menu->setPositionX(winSize.width / 2 + 5); + } } bar->setPositionX(winSize.width / 2); }