Added code for prevent error from double-initialization 87/16787/2
authorJi-hoon Lee <dalton.lee@samsung.com>
Fri, 11 Oct 2013 04:35:10 +0000 (13:35 +0900)
committerJi-hoon Lee <dalton.lee@samsung.com>
Wed, 5 Mar 2014 06:33:34 +0000 (22:33 -0800)
Change-Id: I8d46ce23c2e7dd078801c085d47593ac0ab04164

scl/gwes/efl/sclevents-efl.cpp
scl/gwes/efl/sclwindows-efl.cpp
scl/include/sclwindows.h
scl/sclwindows.cpp
sclres/sclres_manager.cpp
sclres/sclres_manager.h

index 76887ac..307bb44 100644 (file)
@@ -245,48 +245,49 @@ Eina_Bool mouse_press(void *data, int type, void *event_info)
                 // Update the position of the target window
                 //windows->get_window_context(window, TRUE);
                 SclWindowContext *winctx = windows->get_window_context(window);
-                windows->get_window_rect(window, &(winctx->geometry));
-                if (get_window_rect(window, &rect)) {
-                    int adjustx = ev->root.x;
-                    int adjusty = ev->root.y;
-
-                    SclResParserManager *sclres_manager = SclResParserManager::get_instance();
-                    PSclDefaultConfigure default_configure = NULL;
-                    if (sclres_manager) {
-                        default_configure = sclres_manager->get_default_configure();
-                    }
-                    if (default_configure) {
-                        SCLDisplayMode display_mode = context->get_display_mode();
-                        CSCLErrorAdjustment *adjustment = CSCLErrorAdjustment::get_instance();
-                        if (adjustment && scl_check_arrindex(display_mode, DISPLAYMODE_MAX)) {
-                            adjustment->apply_touch_offset(default_configure->touch_offset_level[display_mode], &adjustx, &adjusty);
+                if (winctx) {
+                    windows->get_window_rect(window, &(winctx->geometry));
+                    if (get_window_rect(window, &rect)) {
+                        int adjustx = ev->root.x;
+                        int adjusty = ev->root.y;
+
+                        SclResParserManager *sclres_manager = SclResParserManager::get_instance();
+                        PSclDefaultConfigure default_configure = NULL;
+                        if (sclres_manager) {
+                            default_configure = sclres_manager->get_default_configure();
+                        }
+                        if (default_configure) {
+                            SCLDisplayMode display_mode = context->get_display_mode();
+                            CSCLErrorAdjustment *adjustment = CSCLErrorAdjustment::get_instance();
+                            if (adjustment && scl_check_arrindex(display_mode, DISPLAYMODE_MAX)) {
+                                adjustment->apply_touch_offset(default_configure->touch_offset_level[display_mode], &adjustx, &adjusty);
+                            }
                         }
-                    }
 
-                    sclint winwidth = rect.width;
-                    sclint winheight = rect.height;
-                    if (context->get_display_mode() != DISPLAYMODE_PORTRAIT) {
-                        rect.height = winwidth;
-                        rect.width = winheight;
-                    }
+                        sclint winwidth = rect.width;
+                        sclint winheight = rect.height;
+                        if (context->get_display_mode() != DISPLAYMODE_PORTRAIT) {
+                            rect.height = winwidth;
+                            rect.width = winheight;
+                        }
 
-                    sclboolean process_event = FALSE;
-                    if ((adjustx >= rect.x && adjustx <= (rect.x + winwidth)) &&
-                        (adjusty >= rect.y && adjusty <= (rect.y + winheight))) {
-                            process_event = TRUE;
-                    }
-                    if (process_event)
-                    {
-                        // Now convert the global coordinate to appropriate local coordinate
-                        SclPoint coords = get_rotated_local_coords(ev->root.x, ev->root.y, context->get_rotation(), &rect);
-                        controller->mouse_press(window, coords.x, coords.y, ev->multi.device);
-                        mouse_pressed = TRUE;
-                        processed = TRUE;
-                        pressed_window = window;
+                        sclboolean process_event = FALSE;
+                        if ((adjustx >= rect.x && adjustx <= (rect.x + winwidth)) &&
+                            (adjusty >= rect.y && adjusty <= (rect.y + winheight))) {
+                                process_event = TRUE;
+                        }
+                        if (process_event)
+                        {
+                            // Now convert the global coordinate to appropriate local coordinate
+                            SclPoint coords = get_rotated_local_coords(ev->root.x, ev->root.y, context->get_rotation(), &rect);
+                            controller->mouse_press(window, coords.x, coords.y, ev->multi.device);
+                            mouse_pressed = TRUE;
+                            processed = TRUE;
+                            pressed_window = window;
+                        }
                     }
                 }
             }
-
             index++;
         } while (index < MAX_ZORDER_NUM && window != SCLWINDOW_INVALID && !processed);
 
@@ -353,46 +354,47 @@ Eina_Bool mouse_release (void *data, int type, void *event_info)
                 window = windows->get_nth_window_in_Z_order_list(index);
                 if (window) {
                     SclWindowContext *winctx = windows->get_window_context(window);
-                    windows->get_window_rect(window, &(winctx->geometry));
-                    if (get_window_rect(window, &rect)) {
-                        int adjustx = ev->root.x;
-                        int adjusty = ev->root.y;
-
-                        SclResParserManager *sclres_manager = SclResParserManager::get_instance();
-                        PSclDefaultConfigure default_configure = NULL;
-                        if (sclres_manager) {
-                            default_configure = sclres_manager->get_default_configure();
-                        }
-                        if (default_configure) {
-                            SCLDisplayMode display_mode = context->get_display_mode();
-                            CSCLErrorAdjustment *adjustment = CSCLErrorAdjustment::get_instance();
-                            if (adjustment && scl_check_arrindex(display_mode, DISPLAYMODE_MAX)) {
-                                adjustment->apply_touch_offset(default_configure->touch_offset_level[display_mode], &adjustx, &adjusty);
+                    if (winctx) {
+                        windows->get_window_rect(window, &(winctx->geometry));
+                        if (get_window_rect(window, &rect)) {
+                            int adjustx = ev->root.x;
+                            int adjusty = ev->root.y;
+
+                            SclResParserManager *sclres_manager = SclResParserManager::get_instance();
+                            PSclDefaultConfigure default_configure = NULL;
+                            if (sclres_manager) {
+                                default_configure = sclres_manager->get_default_configure();
+                            }
+                            if (default_configure) {
+                                SCLDisplayMode display_mode = context->get_display_mode();
+                                CSCLErrorAdjustment *adjustment = CSCLErrorAdjustment::get_instance();
+                                if (adjustment && scl_check_arrindex(display_mode, DISPLAYMODE_MAX)) {
+                                    adjustment->apply_touch_offset(default_configure->touch_offset_level[display_mode], &adjustx, &adjusty);
+                                }
                             }
-                        }
 
-                        sclint winwidth = rect.width;
-                        sclint winheight = rect.height;
-                        if (context->get_display_mode() != DISPLAYMODE_PORTRAIT) {
-                            rect.height = winwidth;
-                            rect.width = winheight;
-                        }
+                            sclint winwidth = rect.width;
+                            sclint winheight = rect.height;
+                            if (context->get_display_mode() != DISPLAYMODE_PORTRAIT) {
+                                rect.height = winwidth;
+                                rect.width = winheight;
+                            }
 
-                        sclboolean process_event = FALSE;
-                        if ((adjustx >= rect.x && adjustx <= (rect.x + winwidth)) &&
-                            (adjusty >= rect.y && adjusty <= (rect.y + winheight))) {
-                                process_event = TRUE;
-                        }
-                        if (process_event)
-                        {
-                            /* Now convert the global coordinate to appropriate local coordinate */
-                            SclPoint coords = get_rotated_local_coords(ev->root.x, ev->root.y, context->get_rotation(), &rect);
-                            controller->mouse_release(window, coords.x, coords.y, ev->multi.device);
-                            processed = TRUE;
+                            sclboolean process_event = FALSE;
+                            if ((adjustx >= rect.x && adjustx <= (rect.x + winwidth)) &&
+                                (adjusty >= rect.y && adjusty <= (rect.y + winheight))) {
+                                    process_event = TRUE;
+                            }
+                            if (process_event)
+                            {
+                                /* Now convert the global coordinate to appropriate local coordinate */
+                                SclPoint coords = get_rotated_local_coords(ev->root.x, ev->root.y, context->get_rotation(), &rect);
+                                controller->mouse_release(window, coords.x, coords.y, ev->multi.device);
+                                processed = TRUE;
+                            }
                         }
                     }
                 }
-
                 index++;
             } while (index < MAX_ZORDER_NUM && window != SCLWINDOW_INVALID && !processed);
         }
@@ -462,57 +464,58 @@ Eina_Bool mouse_move (void *data, int type, void *event_info)
                 window = windows->get_nth_window_in_Z_order_list(index);
                 if (window) {
                     SclWindowContext *winctx = windows->get_window_context(window);
-                    windows->get_window_rect(window, &(winctx->geometry));
-                    if (get_window_rect(window, &rect)) {
-                        int adjustx = ev->root.x;
-                        int adjusty = ev->root.y;
-
-                        SclResParserManager *sclres_manager = SclResParserManager::get_instance();
-                        PSclDefaultConfigure default_configure = NULL;
-                        if (sclres_manager) {
-                            default_configure = sclres_manager->get_default_configure();
-                        }
-                        if (default_configure) {
-                            SCLDisplayMode display_mode = context->get_display_mode();
-                            CSCLErrorAdjustment *adjustment = CSCLErrorAdjustment::get_instance();
-                            if (adjustment && scl_check_arrindex(display_mode, DISPLAYMODE_MAX)) {
-                                adjustment->apply_touch_offset(default_configure->touch_offset_level[display_mode], &adjustx, &adjusty);
+                    if (winctx) {
+                        windows->get_window_rect(window, &(winctx->geometry));
+                        if (get_window_rect(window, &rect)) {
+                            int adjustx = ev->root.x;
+                            int adjusty = ev->root.y;
+
+                            SclResParserManager *sclres_manager = SclResParserManager::get_instance();
+                            PSclDefaultConfigure default_configure = NULL;
+                            if (sclres_manager) {
+                                default_configure = sclres_manager->get_default_configure();
+                            }
+                            if (default_configure) {
+                                SCLDisplayMode display_mode = context->get_display_mode();
+                                CSCLErrorAdjustment *adjustment = CSCLErrorAdjustment::get_instance();
+                                if (adjustment && scl_check_arrindex(display_mode, DISPLAYMODE_MAX)) {
+                                    adjustment->apply_touch_offset(default_configure->touch_offset_level[display_mode], &adjustx, &adjusty);
+                                }
                             }
-                        }
 
-                        sclint winwidth = rect.width;
-                        sclint winheight = rect.height;
-                        if (context->get_display_mode() != DISPLAYMODE_PORTRAIT) {
-                            rect.height = winwidth;
-                            rect.width = winheight;
-                        }
+                            sclint winwidth = rect.width;
+                            sclint winheight = rect.height;
+                            if (context->get_display_mode() != DISPLAYMODE_PORTRAIT) {
+                                rect.height = winwidth;
+                                rect.width = winheight;
+                            }
 
-                        sclboolean process_event = FALSE;
-                        if ((adjustx >= rect.x && adjustx <= (rect.x + winwidth)) &&
-                            (adjusty >= rect.y && adjusty <= (rect.y + winheight))) {
-                                process_event = TRUE;
-                        }
-                        /* Process this event regardless of the coordinate if the top window has the POPUP_GRAB layout style */
-                        if (index == SCL_WINDOW_Z_TOP) {
-                            const SclLayout *layout = cache->get_cur_layout(window);
-                            if (layout) {
-                                if (layout->style == LAYOUT_STYLE_POPUP_GRAB) {
+                            sclboolean process_event = FALSE;
+                            if ((adjustx >= rect.x && adjustx <= (rect.x + winwidth)) &&
+                                (adjusty >= rect.y && adjusty <= (rect.y + winheight))) {
                                     process_event = TRUE;
+                            }
+                            /* Process this event regardless of the coordinate if the top window has the POPUP_GRAB layout style */
+                            if (index == SCL_WINDOW_Z_TOP) {
+                                const SclLayout *layout = cache->get_cur_layout(window);
+                                if (layout) {
+                                    if (layout->style == LAYOUT_STYLE_POPUP_GRAB) {
+                                        process_event = TRUE;
+                                    }
                                 }
                             }
-                        }
-                        if (process_event)
-                        {
-                            /* Now convert the global coordinate to appropriate local coordinate */
-                            SclPoint coords = get_rotated_local_coords(ev->root.x, ev->root.y, context->get_rotation(), &rect);
+                            if (process_event)
+                            {
+                                /* Now convert the global coordinate to appropriate local coordinate */
+                                SclPoint coords = get_rotated_local_coords(ev->root.x, ev->root.y, context->get_rotation(), &rect);
 
-                            controller->mouse_move(window, coords.x, coords.y, ev->multi.device);
-                            processed = TRUE;
+                                controller->mouse_move(window, coords.x, coords.y, ev->multi.device);
+                                processed = TRUE;
+                            }
                         }
-
-                        index++;
                     }
                 }
+                index++;
             } while (index < MAX_ZORDER_NUM && window != SCLWINDOW_INVALID && !processed);
         }
 
index eb4fa19..b6c9c75 100644 (file)
@@ -358,46 +358,52 @@ CSCLWindowsImplEfl::destroy_window(sclwindow window)
 
     if (windows && utils && winctx) {
         if (winctx->etc_info) {
-            while ((Eina_List*)(winctx->etc_info)) {
-                EFLObject *object = (EFLObject*)eina_list_data_get((Eina_List*)(winctx->etc_info));
-                if (object) {
-                    Evas_Object* eo = object->object;
-                    if (object->extracted) {
-                        //evas_object_image_data_set(eo, NULL);
-                        void *data = evas_object_image_data_get(eo, 1);
-                        if (data) {
-                            free(data);
+            Eina_List *list = (Eina_List*)(winctx->etc_info);
+            Eina_List *iter = NULL;
+            Eina_List *iter_next = NULL;
+            void *data = NULL;
+
+            EINA_LIST_FOREACH_SAFE(list, iter, iter_next, data) {
+                if (data) {
+                    EFLObject *object = (EFLObject*)(data);
+                    if (object) {
+                        Evas_Object* eo = object->object;
+                        if (object->extracted) {
+                            //evas_object_image_data_set(eo, NULL);
+                            void *data = evas_object_image_data_get(eo, 1);
+                            if (data) {
+                                free(data);
+                            }
                         }
-                    }
-                    if (eo) {
-                        evas_object_del(eo);
-                        object->object = NULL;
-                    }
-                    if (object->type == EFLOBJECT_TEXTBLOCK) {
-                        Evas_Textblock_Style *st = (Evas_Textblock_Style*)(object->data);
-                        if (st) {
-                            evas_textblock_style_free(st);
+                        if (eo) {
+                            evas_object_del(eo);
+                            object->object = NULL;
                         }
+                        if (object->type == EFLOBJECT_TEXTBLOCK) {
+                            Evas_Textblock_Style *st = (Evas_Textblock_Style*)(object->data);
+                            if (st) {
+                                evas_textblock_style_free(st);
+                            }
 #ifdef TEST_NEWBACKEND
-                        for(sclint loop = 0;loop < g_TextCache.size();loop++) {
-                            if (g_TextCache[loop].text == object->object) {
-                                g_TextCache[loop].used = FALSE;
+                            for(sclint loop = 0;loop < g_TextCache.size();loop++) {
+                                if (g_TextCache[loop].text == object->object) {
+                                    g_TextCache[loop].used = FALSE;
+                                }
                             }
-                        }
 #endif
-                    } else if (object->type == EFLOBJECT_IMAGE) {
+                        } else if (object->type == EFLOBJECT_IMAGE) {
 #ifdef TEST_NEWBACKEND
-                        for(sclint loop = 0;loop < g_ImageCache.size();loop++) {
-                            if (g_ImageCache[loop].image == object->object) {
-                                g_ImageCache[loop].used = FALSE;
+                            for(sclint loop = 0;loop < g_ImageCache.size();loop++) {
+                                if (g_ImageCache[loop].image == object->object) {
+                                    g_ImageCache[loop].used = FALSE;
+                                }
                             }
-                        }
 #endif
+                        }
+                        delete object;
                     }
                 }
-                winctx->etc_info = eina_list_remove_list((Eina_List*)(winctx->etc_info), (Eina_List*)(winctx->etc_info));
-                if (object)
-                    delete object;
+                list = eina_list_remove_list(list, iter);
             }
             winctx->etc_info = NULL;
         }
index f474e60..6c3c834 100644 (file)
@@ -159,6 +159,7 @@ private :
     SclWindowContext m_dim_winctx;
 
     sclboolean m_pending_update;
+    sclboolean m_initialized;
 
     sclwindow m_Z_order_list[MAX_ZORDER_NUM];
 };
index 700d6c9..401d7b0 100644 (file)
@@ -66,10 +66,15 @@ CSCLWindows::~CSCLWindows()
 
 void CSCLWindows::init()
 {
+    int loop;
     CSCLWindowsImpl *impl = get_scl_windows_impl();
     if (impl) {
         impl->init();
     }
+    for (loop = 0;loop < MAX_ZORDER_NUM;loop++) {
+        m_Z_order_list[loop] = SCLWINDOW_INVALID;
+    }
+    m_initialized = TRUE;
 }
 
 void CSCLWindows::fini()
@@ -103,6 +108,8 @@ void CSCLWindows::fini()
             }
         }
     }
+
+    m_initialized = FALSE;
 }
 
 CSCLWindowsImpl*
@@ -295,17 +302,19 @@ CSCLWindows::create_base_window(const sclwindow parent, scl16 width, scl16 heigh
 {
     SCL_DEBUG();
 
-    m_base_winctx.hidden = TRUE;
-    m_base_winctx.geometry.width = width;
-    m_base_winctx.geometry.height = height;
-    m_base_winctx.is_virtual = FALSE;
-    m_base_winctx.popup_type = POPUP_TYPE_NONE;
-    m_base_winctx.opener.window = parent;
-    m_base_winctx.geometry.x = m_base_winctx.geometry.y = 0;
-    m_base_winctx.etc_info = NULL;
-    m_base_winctx.window = get_scl_windows_impl()->create_base_window(parent, &m_base_winctx, width, height);
-
-    push_window_in_Z_order_list(m_base_winctx.window);
+    if (m_initialized) {
+        m_base_winctx.hidden = TRUE;
+        m_base_winctx.geometry.width = width;
+        m_base_winctx.geometry.height = height;
+        m_base_winctx.is_virtual = FALSE;
+        m_base_winctx.popup_type = POPUP_TYPE_NONE;
+        m_base_winctx.opener.window = parent;
+        m_base_winctx.geometry.x = m_base_winctx.geometry.y = 0;
+        m_base_winctx.etc_info = NULL;
+        m_base_winctx.window = get_scl_windows_impl()->create_base_window(parent, &m_base_winctx, width, height);
+
+        push_window_in_Z_order_list(m_base_winctx.window);
+    }
 
     // Update the position information
     //get_window_context(parent, TRUE);
@@ -385,8 +394,8 @@ CSCLWindows::create_magnifier_window(const sclwindow parent, scl16 x, scl16 y, s
     CSCLWindowsImpl* impl = get_scl_windows_impl();
     sclwindow window = SCLWINDOW_INVALID;
 
-    if (impl) {
-        if (m_magnifier_winctx.window == NULL) {
+    if (impl && m_initialized) {
+        if (m_magnifier_winctx.window == SCLWINDOW_INVALID) {
             window = impl->create_magnifier_window(parent, &m_magnifier_winctx, width, height);
             impl->set_keep_above(window, TRUE);
             if (window) {
@@ -434,7 +443,7 @@ CSCLWindows::create_dim_window(const sclwindow parent, SclWindowContext *winctx,
         default_configure = sclres_manager->get_default_configure();
     }
 
-    if (impl && default_configure) {
+    if (impl && m_initialized && default_configure) {
         if (m_dim_winctx.window == NULL) {
             m_dim_winctx.hidden = TRUE;
             if (default_configure->use_actual_dim_window) {
index 76506ec..658987c 100644 (file)
@@ -29,6 +29,7 @@ static sclres::SclRes *_current_parser = NULL;
 
 SclResParserManager::~SclResParserManager() {
     _current_parser = NULL;
+    m_initialized = false;
 }
 
 SclResParserManager*
@@ -39,43 +40,47 @@ SclResParserManager::get_instance() {
 
 SclResParserManager::SclResParserManager() {
     _current_parser = NULL;
+    m_initialized = false;
 }
 
 void
 SclResParserManager::init(const SCLParserType parser_type, const char *entry_filepath) {
-    if (parser_type == SCL_PARSER_TYPE_XML) {
-        SCLLOG(SclLog::MESSAGE, "Use text xml\n");
-        _current_parser = XMLResource::get_instance();
-    }
-    else if (parser_type == SCL_PARSER_TYPE_BINARY_XML) {
-        SCLLOG(SclLog::MESSAGE, "Use binary xml\n");
-        _current_parser = BinResource::get_instance();
-    }
-
-    /* Let's acquire the directory information from filepath */
-    std::string str = entry_filepath;
-    size_t found;
-    found = str.find_last_of("/\\");
-
-    std::string filepath = str.substr(0, found);
-    std::string filename = str.substr(found + 1);
-
-    //assert(_current_parser != NULL);
-    if (_current_parser != NULL) {
-        /* Assume the directory where the main entry file exists, is the default resource directory */
-        _current_parser->set_resource_directory(filepath.c_str());
-        _current_parser->init(filename.c_str());
+    if (!m_initialized) {
+        if (parser_type == SCL_PARSER_TYPE_XML) {
+            SCLLOG(SclLog::MESSAGE, "Use text xml\n");
+            _current_parser = XMLResource::get_instance();
+        }
+        else if (parser_type == SCL_PARSER_TYPE_BINARY_XML) {
+            SCLLOG(SclLog::MESSAGE, "Use binary xml\n");
+            _current_parser = BinResource::get_instance();
+        }
+
+        /* Let's acquire the directory information from filepath */
+        std::string str = entry_filepath;
+        size_t found;
+        found = str.find_last_of("/\\");
+
+        std::string filepath = str.substr(0, found);
+        std::string filename = str.substr(found + 1);
+
+        //assert(_current_parser != NULL);
+        if (_current_parser != NULL) {
+            /* Assume the directory where the main entry file exists, is the default resource directory */
+            _current_parser->set_resource_directory(filepath.c_str());
+            _current_parser->init(filename.c_str());
 #ifdef __SCL_TXT_DEBUG
-        put_autopopup_configure(PARSER, *(_current_parser->get_autopopup_configure()));
-        put_default_configure(PARSER, *(_current_parser->get_default_configure()));
-        put_input_mode_configure_table(PARSER, _current_parser->get_input_mode_configure_table());
-        put_key_coordinate_frame(PARSER, _current_parser->get_key_coordinate_pointer_frame());
-        put_label_properties_frame(PARSER, _current_parser->get_label_properties_frame());
-        put_layout_table(PARSER, _current_parser->get_layout_table());
-        put_magnifier_wnd_configure(PARSER, *(_current_parser->get_magnifier_configure()));
-        put_modifier_decoration(PARSER, _current_parser->get_modifier_decoration_table());
-        //put_nine_patch_info(PARSER, _current_parser->get_nine_patch_file_list());
+            put_autopopup_configure(PARSER, *(_current_parser->get_autopopup_configure()));
+            put_default_configure(PARSER, *(_current_parser->get_default_configure()));
+            put_input_mode_configure_table(PARSER, _current_parser->get_input_mode_configure_table());
+            put_key_coordinate_frame(PARSER, _current_parser->get_key_coordinate_pointer_frame());
+            put_label_properties_frame(PARSER, _current_parser->get_label_properties_frame());
+            put_layout_table(PARSER, _current_parser->get_layout_table());
+            put_magnifier_wnd_configure(PARSER, *(_current_parser->get_magnifier_configure()));
+            put_modifier_decoration(PARSER, _current_parser->get_modifier_decoration_table());
+            //put_nine_patch_info(PARSER, _current_parser->get_nine_patch_file_list());
 #endif
+        }
+        m_initialized = true;
     }
 }
 
index ae93467..e565557 100644 (file)
@@ -55,6 +55,7 @@ class SclResParserManager{
         void destroy();
     private:
         SclResParserManager();
+        bool m_initialized;
 };
 
 #endif