aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorinmarket <andrewh@inmarket.com.au>2015-04-29 22:43:47 +1000
committerinmarket <andrewh@inmarket.com.au>2015-04-29 22:43:47 +1000
commit83c0eb35261704499bad756049c158133f7486eb (patch)
tree433f64a2e0122a1fd97a6608fcba9236fdf7ce04
parent54d4f3d95bb1a8f740608e83cfad58f6b7fc18c0 (diff)
downloaduGFX-83c0eb35261704499bad756049c158133f7486eb.tar.gz
uGFX-83c0eb35261704499bad756049c158133f7486eb.tar.bz2
uGFX-83c0eb35261704499bad756049c158133f7486eb.zip
Workaround for dynamically sized labels crashing sometimes when the text size is changed.
A real fix requires more work on the redraw handler.
-rw-r--r--src/gwin/gwin_label.c14
1 files changed, 11 insertions, 3 deletions
diff --git a/src/gwin/gwin_label.c b/src/gwin/gwin_label.c
index 3be9d0a9..a29a9ebc 100644
--- a/src/gwin/gwin_label.c
+++ b/src/gwin/gwin_label.c
@@ -145,9 +145,17 @@ static void gwinLabelDefaultDraw(GWidgetObject *gw, void *param) {
c = (gw->g.flags & GWIN_FLG_SYSENABLED) ? gw->pstyle->enabled.text : gw->pstyle->disabled.text;
if (gw->g.width != w || gw->g.height != h) {
- gwinResize(&gw->g, w, h);
-
- return;
+ /* Only allow the widget to be resize if it will grow larger.
+ * Growing smaller is problematic because it requires a temporary change in visibility.
+ * This is a work-around for a crashing bug caused by calling gwinResize() in the draw function
+ * (dubious) as it may try to reclaim the drawing lock.
+ */
+ if (gw->g.width < w || gw->g.height < h) {
+ gwinResize(&gw->g, (w > gw->g.width ? w : gw->g.width), (h > gw->g.height ? h : gw->g.height));
+ return;
+ }
+ w = gw->g.width;
+ h = gw->g.height;
}
#if GWIN_LABEL_ATTRIBUTE