From a15031733b27cd71516b419056e4ac765ab9c60e Mon Sep 17 00:00:00 2001 From: Aloshi Date: Tue, 9 Jul 2013 18:52:10 -0500 Subject: [PATCH] Fix crash when no fast-select font specified --- src/components/GuiFastSelect.cpp | 9 ++++++--- src/components/ThemeComponent.cpp | 2 +- 2 files changed, 7 insertions(+), 4 deletions(-) diff --git a/src/components/GuiFastSelect.cpp b/src/components/GuiFastSelect.cpp index c53893cf5..555c3f571 100644 --- a/src/components/GuiFastSelect.cpp +++ b/src/components/GuiFastSelect.cpp @@ -41,11 +41,14 @@ void GuiFastSelect::render() mBox->render(); - mTheme->getFastSelectFont()->drawCenteredText(LETTERS.substr(mLetterID, 1), 0, (int)(sh * 0.5f - (mTheme->getFastSelectFont()->getHeight() * 0.5f)), mTextColor); - mTheme->getDescriptionFont()->drawCenteredText("Sort order:", 0, (int)(sh * 0.6f - (mTheme->getDescriptionFont()->getHeight() * 0.5f)), mTextColor); + std::shared_ptr letterFont = mTheme->getFastSelectFont(); + std::shared_ptr subtextFont = mTheme->getDescriptionFont(); + + letterFont->drawCenteredText(LETTERS.substr(mLetterID, 1), 0, (int)(sh * 0.5f - (letterFont->getHeight() * 0.5f)), mTextColor); + subtextFont->drawCenteredText("Sort order:", 0, (int)(sh * 0.6f - (subtextFont->getHeight() * 0.5f)), mTextColor); std::string sortString = "<- " + mParent->getSortState().description + " ->"; - mTheme->getDescriptionFont()->drawCenteredText(sortString, 0, (int)(sh * 0.6f + (mTheme->getDescriptionFont()->getHeight() * 0.5f)), mTextColor); + subtextFont->drawCenteredText(sortString, 0, (int)(sh * 0.6f + (subtextFont->getHeight() * 0.5f)), mTextColor); } bool GuiFastSelect::input(InputConfig* config, Input input) diff --git a/src/components/ThemeComponent.cpp b/src/components/ThemeComponent.cpp index 9643f3dbf..12cde07fd 100644 --- a/src/components/ThemeComponent.cpp +++ b/src/components/ThemeComponent.cpp @@ -53,7 +53,7 @@ std::shared_ptr ThemeComponent::getDescriptionFont() std::shared_ptr ThemeComponent::getFastSelectFont() { - if(mFastSelectFont == NULL) + if(mFastSelectFont) return mFastSelectFont; else return Font::get(*mWindow->getResourceManager(), Font::getDefaultPath(), FONT_SIZE_LARGE);