summaryrefslogtreecommitdiff
path: root/menuitem.c
diff options
context:
space:
mode:
authorlouis <louis.braun@gmx.de>2013-04-07 13:24:06 +0200
committerlouis <louis.braun@gmx.de>2013-04-07 13:24:06 +0200
commit5ef591469268cb364a4194e382a3df1fceda9af9 (patch)
treea60ed67227486babbd6102405196d031e31829b0 /menuitem.c
parent44f62de1524a552968c35ae3e7e1bf9b79d87127 (diff)
downloadskin-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.c4
1 files changed, 4 insertions, 0 deletions
diff --git a/menuitem.c b/menuitem.c
index 8b207bd..1b541bc 100644
--- a/menuitem.c
+++ b/menuitem.c
@@ -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);