1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
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)
@@ -51,6 +51,7 @@
     skins_initialising = false;
 }
 #else
+bool loading_skins = false;
 static size_t skin_buffer_size;
 static char *skin_buffer = NULL;
 static int buflib_move_callback(int handle, void* current, void* new)
@@ -149,7 +150,7 @@
 void settings_apply_skins(void)
 {
     int i, j;
-
+loading_skins = true;
     skin_unload_all();
     /* Make sure each skin is loaded */
     for (i=0; i<SKINNABLE_SCREENS_COUNT; i++)
@@ -165,6 +166,7 @@
     FOR_NB_SCREENS(i)
         skin_backdrop_show(sb_get_backdrop(i));
 #endif
+loading_skins = false;
 }
 
 void skin_load(enum skinnable_screens skin, enum screen_type screen,
Index: firmware/font.c
===================================================================
--- firmware/font.c	(revision 30709)
+++ firmware/font.c	(working copy)
@@ -77,7 +77,7 @@
 
 struct buflib_alloc_data {
     struct font font;
-    bool handle_locked; /* is the buflib handle currently locked? */
+    int handle_locks; /* is the buflib handle currently locked? */
     int refcount;       /* how many times has this font been loaded? */
     unsigned char buffer[];
 };
@@ -87,10 +87,11 @@
 static int buflibmove_callback(int handle, void* current, void* new)
 {
     (void)handle;
+    extern bool loading_skins;
     struct buflib_alloc_data *alloc = (struct buflib_alloc_data*)current;
     size_t diff = new - current;
 
-    if (alloc->handle_locked)
+    if (alloc->handle_locks > 0 || loading_skins)
         return BUFLIB_CB_CANNOT_MOVE;
 
     if (alloc->font.bits)
@@ -114,9 +115,13 @@
 static void lock_font_handle(int handle, bool lock)
 {
     struct buflib_alloc_data *alloc = core_get_data(handle);
-    alloc->handle_locked = lock;
+    if ( lock )
+        alloc->handle_locks++;
+    else
+        alloc->handle_locks--;
 }
 
+
 static struct buflib_callbacks buflibops = {buflibmove_callback, NULL };
 
 static inline struct font *pf_from_handle(int handle)
@@ -457,7 +462,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;