From: INSUN PYO Date: Thu, 24 Oct 2019 08:59:25 +0000 (+0900) Subject: [ITC][device][Non-ACR][Fix incorrect g_main_loop_quit usage] X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=fce9da6a75a55fc241e45484387377323f0f2bb9;p=test%2Ftct%2Fnative%2Fapi.git [ITC][device][Non-ACR][Fix incorrect g_main_loop_quit usage] Change-Id: I552adea5cdf2c59415ea52d5996beb5510a5ee81 (cherry picked from commit 50d44359f55d6dc81c37acd75a085851d194487a) --- diff --git a/src/itc/device/ITs-device.c b/src/itc/device/ITs-device.c index b7715cf19..de5d170b4 100755 --- a/src/itc/device/ITs-device.c +++ b/src/itc/device/ITs-device.c @@ -87,15 +87,12 @@ void DeviceChangedCallback(device_callback_e type, void *value, void *user_data) FPRINTF("[Line : %d][%s] DeviceChangedCallback is called\\n", __LINE__, API_NAMESPACE); #endif - g_bDeviceChangedCallback = true; - if (g_pDeviceMainLoop) - { - g_main_loop_quit(g_pDeviceMainLoop); - g_main_loop_unref(g_pDeviceMainLoop); - g_pDeviceMainLoop = NULL; - } + /* stop main loop */ + g_main_loop_quit(g_pDeviceMainLoop); g_ReturnValueState = false; + g_bDeviceChangedCallback = true; + int val = (int) value; switch ( type ) { case DEVICE_CALLBACK_BATTERY_CAPACITY: @@ -144,12 +141,8 @@ void DeviceChangedCallback(device_callback_e type, void *value, void *user_data) */ gboolean DeviceTimeout(gpointer data) { - if ( g_pDeviceMainLoop ) - { - g_main_loop_quit( g_pDeviceMainLoop ); - g_main_loop_unref( g_pDeviceMainLoop ); - g_pDeviceMainLoop = NULL; - } + /* stop main loop */ + g_main_loop_quit( g_pDeviceMainLoop ); nDeviceTimeoutId = 0; @@ -265,6 +258,7 @@ int ITc_device_add_remove_callback_p(void) g_pDeviceMainLoop = g_main_loop_new(NULL, false); nDeviceTimeoutId = g_timeout_add(TIMEOUT_CB, DeviceTimeout, g_pDeviceMainLoop); g_main_loop_run(g_pDeviceMainLoop); + g_main_loop_unref(g_pDeviceMainLoop); g_pDeviceMainLoop = NULL; if (nDeviceTimeoutId) { @@ -272,7 +266,6 @@ int ITc_device_add_remove_callback_p(void) nDeviceTimeoutId = 0; } - if ( g_bDeviceChangedCallback == false ) { FPRINTF("[Line : %d][%s] device_add_callback failed to invoke callback for enum = %s\\n", __LINE__, API_NAMESPACE, DeviceGetCallbackType(callback_type[enum_counter])); @@ -322,6 +315,7 @@ int ITc_device_add_remove_callback_p(void) g_pDeviceMainLoop = g_main_loop_new(NULL, false); nDeviceTimeoutId = g_timeout_add(TIMEOUT_CB, DeviceTimeout, g_pDeviceMainLoop); g_main_loop_run(g_pDeviceMainLoop); + g_main_loop_unref(g_pDeviceMainLoop); g_pDeviceMainLoop = NULL; if (nDeviceTimeoutId) {