diff options
author | louis <louis.braun@gmx.de> | 2013-04-07 13:24:06 +0200 |
---|---|---|
committer | louis <louis.braun@gmx.de> | 2013-04-07 13:24:06 +0200 |
commit | 5ef591469268cb364a4194e382a3df1fceda9af9 (patch) | |
tree | a60ed67227486babbd6102405196d031e31829b0 /menuitem.c | |
parent | 44f62de1524a552968c35ae3e7e1bf9b79d87127 (diff) | |
download | skin-nopacity-5ef591469268cb364a4194e382a3df1fceda9af9.tar.gz skin-nopacity-5ef591469268cb364a4194e382a3df1fceda9af9.tar.bz2 |
Fixed crash / hang if menu is opened with small screen size
Diffstat (limited to 'menuitem.c')
-rw-r--r-- | menuitem.c | 4 |
1 files changed, 4 insertions, 0 deletions
@@ -155,6 +155,8 @@ void cNopacityMenuItem::DoSleep(int duration) { } std::string cNopacityMenuItem::CutText(std::string *text, int width, const cFont *font) { + if (width <= font->Size()) + return text->c_str(); cTextWrapper twText; twText.Set(text->c_str(), font, width); std::string cuttedTextNative = twText.GetLine(0); @@ -165,6 +167,8 @@ std::string cNopacityMenuItem::CutText(std::string *text, int width, const cFont if (actWidth > width) { int overlap = actWidth - width; int charWidth = font->Width("."); + if (charWidth == 0) + charWidth = 1; int cutChars = overlap / charWidth; if (cutChars > 0) { cuttedTextNative = cuttedTextNative.substr(0, cuttedTextNative.length() - cutChars); |