Avoid trying to load libthai again and again if it's not present
authorSimon Hausmann <simon.hausmann@nokia.com>
Thu, 10 May 2012 08:30:58 +0000 (10:30 +0200)
committerQt by Nokia <qt-info@nokia.com>
Thu, 10 May 2012 09:34:25 +0000 (11:34 +0200)
Change-Id: I3bcbde7bbb307fb27c36709c33c8ff5cd09ab7f8
Reviewed-by: Lars Knoll <lars.knoll@nokia.com>
src/3rdparty/harfbuzz/src/harfbuzz-thai.c

index 3c0ffe8..039394a 100644 (file)
@@ -53,12 +53,14 @@ static th_render_cell_win_def th_render_cell_win = 0;
 static th_render_cell_mac_def th_render_cell_mac = 0;
 
 static int init_libthai() {
-    if (!th_brk || !th_next_cell || !th_render_cell_tis || !th_render_cell_win || !th_render_cell_mac) {
+    static HB_Bool initialized = false;
+    if (!initialized && (!th_brk || !th_next_cell || !th_render_cell_tis || !th_render_cell_win || !th_render_cell_mac)) {
         th_brk = (th_brk_def) HB_Library_Resolve("thai", (int)LIBTHAI_MAJOR, "th_brk");
         th_next_cell = (th_next_cell_def)HB_Library_Resolve("thai", LIBTHAI_MAJOR, "th_next_cell");
         th_render_cell_tis = (th_render_cell_tis_def) HB_Library_Resolve("thai", (int)LIBTHAI_MAJOR, "th_render_cell_tis");
         th_render_cell_win = (th_render_cell_win_def) HB_Library_Resolve("thai", (int)LIBTHAI_MAJOR, "th_render_cell_win");
         th_render_cell_mac = (th_render_cell_mac_def) HB_Library_Resolve("thai", (int)LIBTHAI_MAJOR, "th_render_cell_mac");
+        initialized = true;
     }
     if (th_brk && th_next_cell && th_render_cell_tis && th_render_cell_win && th_render_cell_mac)
         return 1;