Added an extra check in OptionListComponent to avoid potential crashes

This commit is contained in:
Leon Styhre 2024-08-24 12:03:56 +02:00
parent ae779a42e6
commit f7cc0f6ace

View file

@ -343,9 +343,11 @@ private:
mText.setText(ss.str()); mText.setText(ss.str());
mText.setSize(0, mText.getSize().y); mText.setSize(0, mText.getSize().y);
setSize(mText.getTextCache()->metrics.size.x + mRightArrow.getSize().x + setSize(
Font::get(FONT_SIZE_MEDIUM)->getLetterHeight() * 0.68f, (mText.getTextCache() == nullptr ? 0.0f : mText.getTextCache()->metrics.size.x) +
mText.getSize().y); mRightArrow.getSize().x +
Font::get(FONT_SIZE_MEDIUM)->getLetterHeight() * 0.68f,
mText.getSize().y);
if (mParent) if (mParent)
mParent->onSizeChanged(); mParent->onSizeChanged();
} }
@ -363,8 +365,10 @@ private:
} }
mText.setSize(0.0f, mText.getSize().y); mText.setSize(0.0f, mText.getSize().y);
setSize(mText.getTextCache()->metrics.size.x + mLeftArrow.getSize().x + setSize((mText.getTextCache() == nullptr ?
mRightArrow.getSize().x + 0.0f :
mText.getTextCache()->metrics.size.x) +
mLeftArrow.getSize().x + mRightArrow.getSize().x +
Font::get(FONT_SIZE_MEDIUM)->getLetterHeight() * 0.68f, Font::get(FONT_SIZE_MEDIUM)->getLetterHeight() * 0.68f,
mText.getSize().y); mText.getSize().y);
if (mParent) if (mParent)