From f7cc0f6ace4e2e019ab805ca32be208367d764eb Mon Sep 17 00:00:00 2001 From: Leon Styhre Date: Sat, 24 Aug 2024 12:03:56 +0200 Subject: [PATCH] Added an extra check in OptionListComponent to avoid potential crashes --- es-core/src/components/OptionListComponent.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/es-core/src/components/OptionListComponent.h b/es-core/src/components/OptionListComponent.h index de2452282..db310b96e 100644 --- a/es-core/src/components/OptionListComponent.h +++ b/es-core/src/components/OptionListComponent.h @@ -343,9 +343,11 @@ private: mText.setText(ss.str()); mText.setSize(0, mText.getSize().y); - setSize(mText.getTextCache()->metrics.size.x + mRightArrow.getSize().x + - Font::get(FONT_SIZE_MEDIUM)->getLetterHeight() * 0.68f, - mText.getSize().y); + setSize( + (mText.getTextCache() == nullptr ? 0.0f : mText.getTextCache()->metrics.size.x) + + mRightArrow.getSize().x + + Font::get(FONT_SIZE_MEDIUM)->getLetterHeight() * 0.68f, + mText.getSize().y); if (mParent) mParent->onSizeChanged(); } @@ -363,8 +365,10 @@ private: } mText.setSize(0.0f, mText.getSize().y); - setSize(mText.getTextCache()->metrics.size.x + mLeftArrow.getSize().x + - mRightArrow.getSize().x + + setSize((mText.getTextCache() == nullptr ? + 0.0f : + mText.getTextCache()->metrics.size.x) + + mLeftArrow.getSize().x + mRightArrow.getSize().x + Font::get(FONT_SIZE_MEDIUM)->getLetterHeight() * 0.68f, mText.getSize().y); if (mParent)