Fix issues (DEREF_OF_NULLRET.STAT) detected by static analsys tool 09/76009/4
authorInHong Han <inhong1.han@samsung.com>
Wed, 22 Jun 2016 10:23:15 +0000 (19:23 +0900)
committerInHong Han <inhong1.han@samsung.com>
Wed, 22 Jun 2016 11:09:08 +0000 (20:09 +0900)
Change-Id: I5c29fe8123db699679f49e15784989b51c213605

scl/gwes/efl/sclwindows-efl.cpp
scl/sclcontext.cpp
scl/sclcontroller.cpp
scl/sclevents.cpp
scl/sclkeyfocushandler.cpp
scl/scluibuilder.cpp
scl/scluiimpl.cpp
scl/sclutils.cpp

index d7f73df..5143aed 100644 (file)
@@ -166,12 +166,14 @@ CSCLWindowsImplEfl::create_window(const sclwindow parent, SclWindowContext *wind
     scl16 new_width;
     scl16 new_height;
     CSCLContext *context = CSCLContext::get_instance();
-    if (context->get_rotation() == ROTATION_90_CW || context->get_rotation() == ROTATION_90_CCW) {
-        new_width = height;
-        new_height = width;
-    } else {
-        new_width = width;
-        new_height = height;
+    if (context) {
+        if (context->get_rotation() == ROTATION_90_CW || context->get_rotation() == ROTATION_90_CCW) {
+            new_width = height;
+            new_height = width;
+        } else {
+            new_width = width;
+            new_height = height;
+        }
     }
 
 #ifndef FULL_SCREEN_TEST
@@ -213,7 +215,8 @@ CSCLWindowsImplEfl::create_window(const sclwindow parent, SclWindowContext *wind
     }
 #endif
 
-    set_window_rotation(win, context->get_rotation());
+    if (context)
+        set_window_rotation(win, context->get_rotation());
 
     //elm_win_override_set(win, EINA_TRUE);
     if (utils) {
@@ -289,7 +292,8 @@ CSCLWindowsImplEfl::create_magnifier_window(const sclwindow parent, SclWindowCon
 #endif
 
     CSCLContext *context = CSCLContext::get_instance();
-    set_window_rotation(win, context->get_rotation());
+    if (context)
+        set_window_rotation(win, context->get_rotation());
 
     if (utils) {
         utils->log("WinEfl_createmagwin %p, %d %d\n",
@@ -339,7 +343,8 @@ CSCLWindowsImplEfl::create_dim_window(const sclwindow parent, SclWindowContext *
 #endif
 
     CSCLContext *context = CSCLContext::get_instance();
-    set_window_rotation(win, context->get_rotation());
+    if (context)
+        set_window_rotation(win, context->get_rotation());
 
     /*Evas_Object *bg;
     bg = elm_bg_add(win);
index 1396174..b98b513 100644 (file)
@@ -311,9 +311,11 @@ CSCLContext::set_farthest_move_point(scltouchdevice touch_id, sclint x, sclint y
     MultiTouchContext *multi_touch_context = find_multi_touch_context(touch_id);
     if (multi_touch_context) {
         CSCLUtils *utils = CSCLUtils::get_instance();
-        multi_touch_context->farthest_move_dist =
-            utils->get_approximate_distance(x, y,
-            multi_touch_context->cur_pressed_point.x, multi_touch_context->cur_pressed_point.y);
+        if (utils) {
+            multi_touch_context->farthest_move_dist =
+                utils->get_approximate_distance(x, y,
+                multi_touch_context->cur_pressed_point.x, multi_touch_context->cur_pressed_point.y);
+        }
 
         multi_touch_context->farthest_move_point.x = x;
         multi_touch_context->farthest_move_point.y = y;
@@ -537,6 +539,7 @@ CSCLContext::get_multi_touch_event(sclint order, SclUIEventDesc *desc)
 
     CSCLResourceCache *cache = CSCLResourceCache::get_instance();
 
+    if (!cache) return ret;
     for (std::list<scltouchdevice>::iterator list_iter = m_multi_touch_seq.begin();
         !ret && list_iter != m_multi_touch_seq.end();std::advance(list_iter, 1)) {
             if (index == order) {
index 8cb53e2..93b8825 100644 (file)
@@ -43,7 +43,7 @@ _play_tts_for_input_mode_name(int mode) {
     SCL_DEBUG();
 
     CSCLContext *context = CSCLContext::get_instance();
-    if (context->get_tts_enabled() == FALSE) {
+    if (context && context->get_tts_enabled() == FALSE) {
         return FALSE;
     }
 
@@ -59,7 +59,8 @@ _play_tts_for_input_mode_name(int mode) {
     }
 
     CSCLUtils *utils = CSCLUtils::get_instance();
-    utils->play_tts(name);
+    if (utils)
+        utils->play_tts(name);
     return TRUE;
 }
 
@@ -68,12 +69,13 @@ _play_tts_for_layout_autopopup_name() {
     SCL_DEBUG();
 
     CSCLContext *context = CSCLContext::get_instance();
-    if (context->get_tts_enabled() == FALSE) {
+    if (context && context->get_tts_enabled() == FALSE) {
         return FALSE;
     }
 
     CSCLUtils *utils = CSCLUtils::get_instance();
-    utils->play_tts(SCL_LAYOUT_AUTOPOPUP_NAME);
+    if (utils)
+        utils->play_tts(SCL_LAYOUT_AUTOPOPUP_NAME);
     return TRUE;
 }
 
index 2e28f47..1a778e0 100644 (file)
@@ -149,7 +149,8 @@ CSCLEvents::process_key_event(const char *key)
         focus_window = focus_handler->get_current_focus_window();
         key_index = focus_handler->get_current_focus_key();
     } else if ((strcmp(keyname, "Return") == 0) || (strcmp(keyname, "Enter") == 0)) {
-        coordinate = cache->get_cur_layout_key_coordinate(current_focus_window, current_key_index);
+        if (cache)
+            coordinate = cache->get_cur_layout_key_coordinate(current_focus_window, current_key_index);
         //button_context->state = BUTTON_STATE_NORMAL;
         if (coordinate && controller) {
             controller->mouse_press(current_focus_window, coordinate->x, coordinate->y, TRUE);
@@ -169,8 +170,10 @@ CSCLEvents::process_key_event(const char *key)
     }
 
     if (current_key_index != key_index || current_focus_window != focus_window) {
-        prevcoordinate = cache->get_cur_layout_key_coordinate(current_focus_window, current_key_index);
-        coordinate = cache->get_cur_layout_key_coordinate(focus_window, key_index);
+        if (cache) {
+            prevcoordinate = cache->get_cur_layout_key_coordinate(current_focus_window, current_key_index);
+            coordinate = cache->get_cur_layout_key_coordinate(focus_window, key_index);
+        }
         //prev_button_context->state = BUTTON_STATE_NORMAL;
         //button_context->state = BUTTON_STATE_PRESSED;
         if (coordinate && prevcoordinate) {
index b0c2d3d..4729c79 100644 (file)
@@ -274,7 +274,7 @@ CSCLKeyFocusHandler::get_next_candidate_key(SCLHighlightNavigationDirection dire
             layout = context->get_popup_layout(window);
         }
     }
-    if (sclres_layout_key_coordinate_pointer_frame && cache && scl_check_arrindex(layout, MAX_SCL_LAYOUT)) {
+    if (sclres_layout_key_coordinate_pointer_frame && cache && context && scl_check_arrindex(layout, MAX_SCL_LAYOUT)) {
         for (sclint loop = 0;loop < MAX_KEY; loop++) {
             SclLayoutKeyCoordinatePointer p = sclres_layout_key_coordinate_pointer_frame[layout][loop];
             if (p && (loop != m_focus_key || window != m_focus_window)) {
index b010827..49ea154 100644 (file)
@@ -110,13 +110,16 @@ CSCLUIBuilder::init(sclwindow parent)
         }
 
         CSCLContext *context = CSCLContext::get_instance();
-        context->set_display_mode(display_mode);
-        context->set_input_mode(mode);
-        context->set_base_layout(sclres_manager->get_layout_id(sclres_input_mode_configure[mode].layouts[display_mode]));
+        if (context) {
+            context->set_display_mode(display_mode);
+            context->set_input_mode(mode);
+            context->set_base_layout(sclres_manager->get_layout_id(sclres_input_mode_configure[mode].layouts[display_mode]));
+        }
 
         CSCLResourceCache *cache = CSCLResourceCache::get_instance();
         sclwindow window = m_gwes->m_windows->get_base_window();
-        cache->recompute_layout(window);
+        if (cache)
+            cache->recompute_layout(window);
 
         /* Creates the magnifier window */
         if (default_configure && magnifier_configure) {
@@ -446,7 +449,9 @@ CSCLUIBuilder::draw_button_label(const sclwindow window, const scldrawctx draw_c
     CSCLWindows *windows = CSCLWindows::get_instance();
     CSCLGraphics *graphics = CSCLGraphics::get_instance();
     CSCLResourceCache *cache = CSCLResourceCache::get_instance();
-    const SclLayoutKeyCoordinate* coordinate = cache->get_cur_layout_key_coordinate(window, key_index);
+    const SclLayoutKeyCoordinate* coordinate = NULL;
+    if (cache)
+        coordinate = cache->get_cur_layout_key_coordinate(window, key_index);
 
     scl_assert_return_false(window);
     scl_assert_return_false(draw_ctx);
@@ -574,7 +579,9 @@ CSCLUIBuilder::draw_button_label(const sclwindow window, const scldrawctx draw_c
                     info.is_bold = info.is_italic = true;
 
                     CSCLContext *context = CSCLContext::get_instance();
-                    SCLShiftState shiftstate = context->get_shift_state();
+                    SCLShiftState shiftstate;
+                    if (context)
+                        shiftstate = context->get_shift_state();
                     if (labelproperties->shadow_distance > 0 && labelproperties->shadow_color[shiftstate][state].a != 0) {
                         sclint deltax = 0;
                         sclint deltay = 0;
@@ -742,7 +749,9 @@ CSCLUIBuilder::draw_button_bg_by_img(const sclwindow window, const scldrawctx dr
     CSCLWindows *windows = CSCLWindows::get_instance();
     CSCLGraphics *graphics = CSCLGraphics::get_instance();
     CSCLResourceCache *cache = CSCLResourceCache::get_instance();
-    const SclLayoutKeyCoordinate* coordinate = cache->get_cur_layout_key_coordinate(window, key_index);
+    const SclLayoutKeyCoordinate* coordinate = NULL;
+    if (cache)
+        coordinate = cache->get_cur_layout_key_coordinate(window, key_index);
 
     SclResParserManager *sclres_manager = SclResParserManager::get_instance();
     PSclModifierDecoration sclres_modifier_decoration = sclres_manager->get_modifier_decoration_table();
index 7651585..0a8d735 100644 (file)
@@ -121,7 +121,7 @@ CSCLUIImpl::show()
         CSCLContext *context = CSCLContext::get_instance();
         CSCLController *controller = CSCLController::get_instance();
 
-        if (windows && controller && context) {
+        if (utils && windows && controller && context) {
             //if (auto_relocate) {
             if (TRUE) {
                 /* Let's relocate our base window - bottomed center aligned */
index e615894..fd8f99c 100644 (file)
@@ -316,7 +316,7 @@ CSCLUtils::get_autopopup_window_variables(sclchar * const autopopup_keys[MAX_SIZ
         this->get_screen_resolution(&scrx, &scry);
 
         CSCLContext *context = CSCLContext::get_instance();
-        if (context->get_display_mode() == DISPLAYMODE_LANDSCAPE) {
+        if (context && context->get_display_mode() == DISPLAYMODE_LANDSCAPE) {
             int  swap = scrx;
             scrx = scry;
             scry = swap;