Index: apps/gui/skin_engine/skin_engine.c =================================================================== --- apps/gui/skin_engine/skin_engine.c (revision 30709) +++ apps/gui/skin_engine/skin_engine.c (working copy) @@ -149,7 +149,12 @@ void settings_apply_skins(void) { int i, j; - +#ifdef HAVE_LCD_BITMAP + /* don't move any fonts until new theme loaded */ + /* FIXME: make this more precise or force */ + /* after skin_unload_all(); */ + font_lock_all(true); +#endif skin_unload_all(); /* Make sure each skin is loaded */ for (i=0; ihandle_locked) + if (alloc->handle_locks > 0 || lock_all > 0) return BUFLIB_CB_CANNOT_MOVE; if (alloc->font.bits) @@ -111,12 +112,32 @@ return BUFLIB_CB_OK; } + static void lock_font_handle(int handle, bool lock) { + if ( handle == -1 ) + return; struct buflib_alloc_data *alloc = core_get_data(handle); - alloc->handle_locked = lock; + if ( lock ) + alloc->handle_locks++; + else + alloc->handle_locks--; } +void font_lock(int font, bool lock) +{ + if( font == FONT_SYSFIXED ) + return; + lock_font_handle(buflib_allocations[font], lock); +} + +void font_lock_all(bool lock) +{ + if ( lock ) + lock_all++; + else + lock_all--; +} static struct buflib_callbacks buflibops = {buflibmove_callback, NULL }; static inline struct font *pf_from_handle(int handle) @@ -457,7 +478,7 @@ pdata = core_get_data(handle); pf = &pdata->font; font_reset(font_idx); - pdata->handle_locked = false; + pdata->handle_locks = 0; pdata->refcount = 1; pf->buffer_position = pf->buffer_start = buffer_from_handle(handle); pf->buffer_size = size; @@ -930,10 +951,12 @@ */ int font_getstringsize(const unsigned char *str, int *w, int *h, int fontnumber) { - struct font* pf = font_get(fontnumber); + struct font* pf; unsigned short ch; int width = 0; - + + font_lock(fontnumber,true); + pf = font_get(fontnumber); for (str = utf8decode(str, &ch); ch != 0 ; str = utf8decode(str, &ch)) { if (is_diacritic(ch, NULL)) @@ -946,6 +969,7 @@ *w = width; if ( h ) *h = pf->height; + font_lock(fontnumber,false); return width; } Index: firmware/drivers/lcd-bitmap-common.c =================================================================== --- firmware/drivers/lcd-bitmap-common.c (revision 30709) +++ firmware/drivers/lcd-bitmap-common.c (working copy) @@ -101,6 +101,7 @@ static void LCDFN(putsxyofs)(int x, int y, int ofs, const unsigned char *str) { unsigned short *ucs; + font_lock(current_vp->font, true); struct font* pf = font_get(current_vp->font); int vp_flags = current_vp->flags; int rtl_next_non_diac_width, last_non_diacritic_width; @@ -233,6 +234,7 @@ } } } + font_lock(current_vp->font,false); } /* put a string at a given pixel position */ @@ -457,6 +459,7 @@ else s->offset += LCDFN(scroll_info).step; + font_lock(current_vp->font, true); pf = font_get(current_vp->font); xpos = s->startx; ypos = s->y * pf->height + s->y_offset; @@ -490,6 +493,8 @@ LCDFN(putsxyofs_style)(xpos, ypos, s->line, s->style, s->width, pf->height, s->offset); + font_lock(current_vp->font, false); + LCDFN(update_viewport_rect)(xpos, ypos, current_vp->width - xpos, pf->height); }