Fix the exception about checking widget feature 29/60429/3 accepted/tizen/common/20160229.160613 accepted/tizen/ivi/20160226.100204 accepted/tizen/mobile/20160226.100113 accepted/tizen/tv/20160226.100130 accepted/tizen/wearable/20160226.100149 submit/tizen/20160226.071334
authorHwankyu Jhun <h.jhun@samsung.com>
Fri, 26 Feb 2016 06:57:48 +0000 (15:57 +0900)
committerHwankyu Jhun <h.jhun@samsung.com>
Fri, 26 Feb 2016 07:10:41 +0000 (16:10 +0900)
Change-Id: I5ab197ba3ec80bae9a37d1a6cc0b45f4d1f46c5a
Signed-off-by: Hwankyu Jhun <h.jhun@samsung.com>
src/widget_app.c

index b77fe74..905b186 100755 (executable)
@@ -119,7 +119,7 @@ static gint __comp_by_id(gconstpointer a, gconstpointer b)
 {
        widget_context_s *wc = (widget_context_s*)a;
 
-       return strcmp(wc->id, (const char*)b);
+       return strcmp(wc->id, (const char*)b);
 }
 
 static widget_context_s* __find_context_by_id(const char *id)
@@ -173,13 +173,11 @@ static int __instance_create(widget_class_h handle, const char *id, bundle *b)
        bundle_get_str(b, WIDGET_K_WIDTH, &w_str);
        bundle_get_str(b, WIDGET_K_HEIGHT, &h_str);
 
-       if (w_str) {
+       if (w_str)
                w = (int)g_ascii_strtoll(w_str, &remain, 10);
-       }
 
-       if (h_str) {
+       if (h_str)
                h = (int)g_ascii_strtoll(h_str, &remain, 10);
-       }
 
        contexts = g_list_append(contexts, wc);
 
@@ -578,14 +576,20 @@ EXPORT_API int widget_app_get_elm_win(widget_context_h context,
 widget_class_h _widget_class_create(widget_class_s *prev, const char *class_id,
                widget_instance_lifecycle_callback_s callback, void *user_data)
 {
+       widget_class_s *wc;
+
        if (!_is_widget_feature_enabled()) {
                _E("not supported");
                set_last_result(WIDGET_ERROR_NOT_SUPPORTED);
                return NULL;
        }
 
-       widget_class_s *wc = (widget_class_s*)malloc(sizeof(widget_class_s));
+       if (class_id == NULL) {
+               set_last_result(WIDGET_ERROR_INVALID_PARAMETER);
+               return NULL;
+       }
 
+       wc = (widget_class_s *)malloc(sizeof(widget_class_s));
        if (wc == NULL) {
                _E("failed to malloc : %s", __FUNCTION__);
                set_last_result(WIDGET_ERROR_OUT_OF_MEMORY);
@@ -609,27 +613,11 @@ widget_class_h _widget_class_create(widget_class_s *prev, const char *class_id,
 EXPORT_API widget_class_h widget_app_class_add(widget_class_h widget_class, const char *class_id,
                widget_instance_lifecycle_callback_s callback, void *user_data)
 {
-       if (!_is_widget_feature_enabled()) {
-               _E("not supported");
-               set_last_result(WIDGET_ERROR_INVALID_PARAMETER);
-               return NULL;
-       }
-
-       if (class_id == NULL) {
-               set_last_result(WIDGET_ERROR_INVALID_PARAMETER);
-               return NULL;
-       }
-
        return _widget_class_create(widget_class, class_id, callback, user_data);
 }
 
 EXPORT_API widget_class_h widget_app_class_create(widget_instance_lifecycle_callback_s callback, void *user_data)
 {
-       if (!_is_widget_feature_enabled()) {
-               set_last_result(WIDGET_ERROR_INVALID_PARAMETER);
-               return NULL;
-       }
-
        return _widget_class_create(class_provider, appid, callback, user_data);
 }