diff options
| author | Andreas Monzner <andreas.monzner@multimedia-labs.de> | 2006-06-18 19:09:36 +0000 |
|---|---|---|
| committer | Andreas Monzner <andreas.monzner@multimedia-labs.de> | 2006-06-18 19:09:36 +0000 |
| commit | ae3bc8673d79edecb8fcb918d83db011535b0955 (patch) | |
| tree | 3218d825b0856692ff4c795edf734a27a9dcb5dd /lib/gdi | |
| parent | f44dfc20f4ed708d67603f767a976c1168393627 (diff) | |
| download | enigma2-ae3bc8673d79edecb8fcb918d83db011535b0955.tar.gz enigma2-ae3bc8673d79edecb8fcb918d83db011535b0955.zip | |
hopefully fix frequently segfaults
Diffstat (limited to 'lib/gdi')
| -rw-r--r-- | lib/gdi/font.cpp | 21 | ||||
| -rw-r--r-- | lib/gdi/font.h | 2 | ||||
| -rw-r--r-- | lib/gdi/grc.cpp | 5 | ||||
| -rw-r--r-- | lib/gdi/grc.h | 2 |
4 files changed, 16 insertions, 14 deletions
diff --git a/lib/gdi/font.cpp b/lib/gdi/font.cpp index 2ff5fbf7..f7c1bca5 100644 --- a/lib/gdi/font.cpp +++ b/lib/gdi/font.cpp @@ -443,7 +443,7 @@ void eTextPara::setFont(Font *fnt, Font *replacement) void shape (std::vector<unsigned long> &string, const std::vector<unsigned long> &text); -int eTextPara::renderString(const std::string &string, int rflags) +int eTextPara::renderString(const char *string, int rflags) { singleLock s(ftlock); @@ -467,11 +467,12 @@ int eTextPara::renderString(const std::string &string, int rflags) } std::vector<unsigned long> uc_string, uc_visual; - uc_string.reserve(string.length()); + if (string) + uc_string.reserve(strlen(string)); - std::string::const_iterator p(string.begin()); + const char *p = string; - while(p != string.end()) + while(p) { unsigned int unicode=(unsigned char)*p++; @@ -481,28 +482,28 @@ int eTextPara::renderString(const std::string &string, int rflags) { unicode&=0x1F; unicode<<=6; - if (p != string.end()) + if (p) unicode|=(*p++)&0x3F; } else if ((unicode & 0xF0)==0xE0) // three bytes { unicode&=0x0F; unicode<<=6; - if (p != string.end()) + if (p) unicode|=(*p++)&0x3F; unicode<<=6; - if (p != string.end()) + if (p) unicode|=(*p++)&0x3F; } else if ((unicode & 0xF8)==0xF0) // four bytes { unicode&=0x07; unicode<<=6; - if (p != string.end()) + if (p) unicode|=(*p++)&0x3F; unicode<<=6; - if (p != string.end()) + if (p) unicode|=(*p++)&0x3F; unicode<<=6; - if (p != string.end()) + if (p) unicode|=(*p++)&0x3F; } } diff --git a/lib/gdi/font.h b/lib/gdi/font.h index b8983914..6cc238d7 100644 --- a/lib/gdi/font.h +++ b/lib/gdi/font.h @@ -126,7 +126,7 @@ public: static void forceReplacementGlyph(int unicode) { forced_replaces.insert(unicode); } void setFont(const gFont *font); - int renderString(const std::string &string, int flags=0); + int renderString(const char *string, int flags=0); void clear(); diff --git a/lib/gdi/grc.cpp b/lib/gdi/grc.cpp index 274d221b..ef75aace 100644 --- a/lib/gdi/grc.cpp +++ b/lib/gdi/grc.cpp @@ -237,7 +237,7 @@ void gPainter::renderText(const eRect &pos, const std::string &string, int flags o.dc = m_dc.grabRef(); o.parm.renderText = new gOpcode::para::prenderText; o.parm.renderText->area = pos; - o.parm.renderText->text = string; + o.parm.renderText->text = string.empty()?0:strdup(string.c_str()); o.parm.renderText->flags = flags; m_rc->submit(o); } @@ -539,7 +539,8 @@ void gDC::exec(gOpcode *o) assert(m_current_font); para->setFont(m_current_font); para->renderString(o->parm.renderText->text, (flags & gPainter::RT_WRAP) ? RS_WRAP : 0); - + if (o->parm.renderText->text) + free(o->parm.renderText->text); if (flags & gPainter::RT_HALIGN_RIGHT) para->realign(eTextPara::dirRight); else if (flags & gPainter::RT_HALIGN_CENTER) diff --git a/lib/gdi/grc.h b/lib/gdi/grc.h index 58371e79..11355504 100644 --- a/lib/gdi/grc.h +++ b/lib/gdi/grc.h @@ -78,7 +78,7 @@ struct gOpcode struct prenderText { eRect area; - std::string text; + char *text; int flags; } *renderText; |
