From 3b119310507ad8015943a70fd76a1450eb629b4a Mon Sep 17 00:00:00 2001 From: Jihoon Kim Date: Wed, 9 Nov 2016 19:30:13 +0900 Subject: [PATCH] Fix double free issue of eldbus connection Change-Id: I6cc36986623ab57a8f6b5577e5465e9f58fabf50 Signed-off-by: Jihoon Kim --- scl/gwes/efl/sclevents-efl.cpp | 44 ++++++++++++++++++++++-------------------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/scl/gwes/efl/sclevents-efl.cpp b/scl/gwes/efl/sclevents-efl.cpp index 97fb2ce..a850a9e 100644 --- a/scl/gwes/efl/sclevents-efl.cpp +++ b/scl/gwes/efl/sclevents-efl.cpp @@ -47,7 +47,7 @@ using namespace scl; #define E_KEYBOARD_SERVICE_BUS_NAME "org.tizen.keyboard" #define E_KEYBOARD_SERVICE_NAVI_IFC_NAME "org.tizen.KBGestureNavigation" #define E_KEYBOARD_SERVICE_NAVI_OBJ_PATH "/org/tizen/KBGestureNavigation" -static Eldbus_Connection *conn = NULL; +static Eldbus_Connection *eldbus_conn = NULL; typedef enum _Gesture { ONE_FINGER_HOVER = 0, ONE_FINGER_SINGLE_TAP = 15, @@ -228,32 +228,34 @@ static void gesture_cb(void *data, const Eldbus_Message *msg) void gestures_tracker_register() { - Eldbus_Object *obj; - Eldbus_Proxy *proxy; - - eldbus_init(); - LOGD("Registering callback for GestureDetected signal"); - if (!(conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION))) { - LOGD("Error: Unable to get session bus"); - return; - } - obj = eldbus_object_get(conn, E_KEYBOARD_SERVICE_BUS_NAME, E_KEYBOARD_SERVICE_NAVI_OBJ_PATH); - if (!obj) LOGD("Error: Getting object failed"); - - proxy = eldbus_proxy_get(obj, E_KEYBOARD_SERVICE_NAVI_IFC_NAME); - if (!proxy) LOGD("Error: Getting proxy failed"); - if (!eldbus_proxy_signal_handler_add(proxy, "KBGestureDetected", gesture_cb, NULL)) - LOGD("No signal handler returned"); - LOGD("Callback registration successful"); + Eldbus_Object *obj; + Eldbus_Proxy *proxy; + + eldbus_init(); + LOGD("Registering callback for GestureDetected signal"); + if (!(eldbus_conn = eldbus_connection_get(ELDBUS_CONNECTION_TYPE_SESSION))) { + LOGD("Error: Unable to get session bus"); return; + } + obj = eldbus_object_get(eldbus_conn, E_KEYBOARD_SERVICE_BUS_NAME, E_KEYBOARD_SERVICE_NAVI_OBJ_PATH); + if (!obj) LOGD("Error: Getting object failed"); + + proxy = eldbus_proxy_get(obj, E_KEYBOARD_SERVICE_NAVI_IFC_NAME); + if (!proxy) LOGD("Error: Getting proxy failed"); + if (!eldbus_proxy_signal_handler_add(proxy, "KBGestureDetected", gesture_cb, NULL)) + LOGD("No signal handler returned"); + LOGD("Callback registration successful"); + return; } void gestures_tracker_unregister() { - if (conn) - eldbus_connection_unref(conn); + if (eldbus_conn) { + eldbus_connection_unref(eldbus_conn); + eldbus_conn = NULL; + } - eldbus_shutdown(); + eldbus_shutdown(); } #endif /** -- 2.7.4