Fixed issue when application don't use callback function in remote input 77/112677/1
authorInHong Han <inhong1.han@samsung.com>
Thu, 2 Feb 2017 07:13:05 +0000 (16:13 +0900)
committerInHong Han <inhong1.han@samsung.com>
Thu, 2 Feb 2017 07:14:02 +0000 (16:14 +0900)
Added null check code to fix issue
Change-Id: Ie7fc2b00d7f7cd40e44deb0784f07ebcde1fc438

ism/src/isf_remote_control.cpp

index a790b72..0542970 100644 (file)
@@ -25,15 +25,15 @@ struct _remote_control_client {
     guint remote_client_iochannel_err;
     guint remote_client_iochannel_hup;
     int remote_client_id;
-    remote_control_focus_in_cb focus_in_cb;
+    remote_control_focus_in_cb focus_in_cb = NULL;
     void* focus_in_cb_user_data;
-    remote_control_focus_out_cb focus_out_cb;
+    remote_control_focus_out_cb focus_out_cb = NULL;
     void* focus_out_cb_user_data;
-    remote_control_entry_metadata_cb metadata_cb;
+    remote_control_entry_metadata_cb metadata_cb = NULL;
     void* metadata_cb_user_data;
-    remote_control_text_updated_cb text_updated_cb;
+    remote_control_text_updated_cb text_updated_cb = NULL;
     void* text_updated_cb_user_data;
-    remote_control_input_resource_changed_cb input_resource_changed_cb;
+    remote_control_input_resource_changed_cb input_resource_changed_cb = NULL;
     void* input_resource_changed_cb_user_data;
 };
 
@@ -48,14 +48,18 @@ remote_handler(GIOChannel *source, GIOCondition condition, gpointer user_data)
                 {
                     LOGD ("REMOTE_CONTROL_CALLBACK_FOCUS_IN");
                     focus_flag = true;
-                    client->focus_in_cb (client->focus_in_cb_user_data);
+
+                    if (client->focus_in_cb)
+                        client->focus_in_cb (client->focus_in_cb_user_data);
                     break;
                 }
                 case REMOTE_CONTROL_CALLBACK_FOCUS_OUT:
                 {
                     LOGD ("REMOTE_CONTROL_CALLBACK_FOCUS_OUT");
                     focus_flag = false;
-                    client->focus_out_cb (client->focus_out_cb_user_data);
+
+                    if (client->focus_out_cb)
+                        client->focus_out_cb (client->focus_out_cb_user_data);
                     break;
                 }
                 case REMOTE_CONTROL_CALLBACK_ENTRY_METADATA:
@@ -73,7 +77,9 @@ remote_handler(GIOChannel *source, GIOCondition condition, gpointer user_data)
 
                         LOGD ("REMOTE_CONTROL_CALLBACK_ENTRY_METADATA hint: 0x%04x, layout: %d, variation: %d, autocapital: %d, return_key: %d",
                             data->hint, data->layout, data->variation, data->autocapital_type, data->return_key_disabled);
-                        client->metadata_cb (client->metadata_cb_user_data, data);
+
+                        if (client->metadata_cb)
+                            client->metadata_cb (client->metadata_cb_user_data, data);
                         delete data;
                     }
                     break;
@@ -86,7 +92,9 @@ remote_handler(GIOChannel *source, GIOCondition condition, gpointer user_data)
 
                         client->remote_client.get_surrounding_text (surrounding_text, &cursor);
                         SECURE_LOGD ("REMOTE_CONTROL_CALLBACK_TEXT_UPDATED \"%s\" %d", surrounding_text.c_str (), cursor);
-                        client->text_updated_cb (client->text_updated_cb_user_data, surrounding_text.c_str (), cursor);
+
+                        if (client->text_updated_cb)
+                            client->text_updated_cb (client->text_updated_cb_user_data, surrounding_text.c_str (), cursor);
                     }
                     break;
                 }
@@ -97,8 +105,10 @@ remote_handler(GIOChannel *source, GIOCondition condition, gpointer user_data)
 
                         client->remote_client.get_input_resource (&resource);
                         LOGD ("REMOTE_CONTROL_CALLBACK_INPUT_RESOURCE: %s", (resource ? "REMOTE" : "LOCAL"));
-                        client->input_resource_changed_cb (client->input_resource_changed_cb_user_data,
-                            static_cast<remote_control_input_resource> (resource));
+
+                        if (client->input_resource_changed_cb)
+                            client->input_resource_changed_cb (client->input_resource_changed_cb_user_data,
+                                static_cast<remote_control_input_resource> (resource));
                     }
                     break;
                 }