From 7556761d01aaede53397eeacdfdac01b4499baa0 Mon Sep 17 00:00:00 2001 From: Vitaliy Cherepanov Date: Thu, 19 Dec 2013 20:00:00 +0400 Subject: [PATCH] [FIX] internet application crash The reason is call ecore_x_init before register_orientation_event_listener function. It was fixed by adding ecore_x_init and ecore_x_shutdown handlers. So call register_orientation_event_listener on ecore_x_init first call. Change-Id: I3757147ec0cbc20dbc52d33426c9dca88e170899 Signed-off-by: Vitaliy Cherepanov --- probe_event/da_event.c | 45 ++++++++------------- probe_event/orientation.c | 82 ++++++++++++++++++++++++++++++-------- probe_tizenapi/tizen_lifecycle.cpp | 8 ---- 3 files changed, 82 insertions(+), 53 deletions(-) diff --git a/probe_event/da_event.c b/probe_event/da_event.c index b62eef0..e0476d8 100755 --- a/probe_event/da_event.c +++ b/probe_event/da_event.c @@ -78,41 +78,30 @@ static int convert_angle(int angle) void on_orientation_changed(int angle, bool capi) { probeInfo_t probeInfo; - bool autoRotation = true; probeBlockStart(); internal_angle = angle; - if(runtime_info_get_value_bool( - RUNTIME_INFO_KEY_AUTO_ROTATION_ENABLED, &autoRotation) < 0) - { - PRINTMSG("ERROR: could not get auto rotation value!\n"); - } + external_angle = internal_angle; - if(autoRotation) // rotation is not locked + if(isOptionEnabled(OPT_EVENT)) { - external_angle = internal_angle; - - if(isOptionEnabled(OPT_EVENT)) - { - setProbePoint(&probeInfo); - - PREPARE_LOCAL_BUF(); - PACK_COMMON_BEGIN(MSG_PROBE_UIEVENT, - API_ID_on_orientation_changed, - "dd", angle, (uint32_t)capi); - PACK_COMMON_END('v', 0, 0, 0); - PACK_UIEVENT(_EVENT_ORIENTATION, 0, 0, 0, "", convert_angle(external_angle)); - FLUSH_LOCAL_BUF(); - } - - SCREENSHOT_SET(); -// if(!capi) -// { -// SCREENSHOT_DONE(); -// } + setProbePoint(&probeInfo); + + PREPARE_LOCAL_BUF(); + PACK_COMMON_BEGIN(MSG_PROBE_UIEVENT, + API_ID_on_orientation_changed, + "dd", angle, (uint32_t)capi); + PACK_COMMON_END('v', 0, 0, 0); + PACK_UIEVENT(_EVENT_ORIENTATION, 0, 0, 0, "", convert_angle(external_angle)); + FLUSH_LOCAL_BUF(); } - else { } // do nothing + + SCREENSHOT_SET(); +// if(!capi) +// { +// SCREENSHOT_DONE(); +// } probeBlockEnd(); } diff --git a/probe_event/orientation.c b/probe_event/orientation.c index 3c080d0..3dfe953 100644 --- a/probe_event/orientation.c +++ b/probe_event/orientation.c @@ -34,19 +34,67 @@ #include "daprobe.h" #include "dahelper.h" -Eina_Bool _da_onclientmessagereceived(void __unused * pData, int __unused type, +static int init_orient = 0; + +Ecore_Event_Handler *register_orientation_event_listener(); +void unregister_orientation_event_listener(Ecore_Event_Handler **handler); + +Ecore_Event_Handler *handler = NULL; + +EAPI int ecore_x_init(const char *name) +{ + static int (*ecore_x_initp)(const char *name); + int res; + + probeBlockStart(); + GET_REAL_FUNC(ecore_x_init, LIBOSP_UIFW); + + probeBlockEnd(); + res = ecore_x_initp(name); + + if ((init_orient == 0) && (res == 1)) { + handler = register_orientation_event_listener(); + init_orient = 1; + } + return res; +} + +EAPI int ecore_x_shutdown(void) +{ + static int (*ecore_x_shutdownp)(void); + int res; + + probeBlockStart(); + GET_REAL_FUNC(ecore_x_shutdown, LIBOSP_UIFW); + + probeBlockEnd(); + res = ecore_x_shutdownp(); + + if ((init_orient == 1) && (res == 0)) { + unregister_orientation_event_listener(&handler); + init_orient = 0; + } + + return res; +} + +Eina_Bool _da_onclientmessagereceived(void __unused *pData, int __unused type, void *pEvent) { - Ecore_X_Event_Client_Message* pClientEvent; + Ecore_X_Event_Client_Message *pClientEvent; probeBlockStart(); pClientEvent = (Ecore_X_Event_Client_Message*)pEvent; - if(pClientEvent != NULL) - { - if(pClientEvent->message_type == ECORE_X_ATOM_E_WINDOW_ROTATION_CHANGE_REQUEST) - { - int orientation = pClientEvent->data.l[1]; + //This code from ecore_x + //So I don't know what 32 does mean + if (pClientEvent->format != 32) + return ECORE_CALLBACK_PASS_ON; + + if (pClientEvent != NULL) { + if (pClientEvent->message_type == + ECORE_X_ATOM_E_WINDOW_ROTATION_CHANGE_PREPARE) { + int orientation = (int)pClientEvent->data.l[1]; on_orientation_changed(orientation, false); } } @@ -55,25 +103,25 @@ Eina_Bool _da_onclientmessagereceived(void __unused * pData, int __unused type, return ECORE_CALLBACK_RENEW; } -Ecore_Event_Handler* register_orientation_event_listener() +Ecore_Event_Handler *register_orientation_event_listener() { - Ecore_Event_Handler* handler; - + Ecore_Event_Handler *handler; probeBlockStart(); - ecore_init(); - ecore_x_init(NULL); - handler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, _da_onclientmessagereceived, NULL); + + handler = ecore_event_handler_add(ECORE_X_EVENT_CLIENT_MESSAGE, + _da_onclientmessagereceived, NULL); + probeBlockEnd(); return handler; } -void unregister_orientation_event_listener(Ecore_Event_Handler* handler) +void unregister_orientation_event_listener(Ecore_Event_Handler **handler) { probeBlockStart(); - if(handler) - { - ecore_event_handler_del(handler); + if (*handler) { + ecore_event_handler_del(*handler); + *handler = NULL; } probeBlockEnd(); } diff --git a/probe_tizenapi/tizen_lifecycle.cpp b/probe_tizenapi/tizen_lifecycle.cpp index 5fd5525..86007b0 100755 --- a/probe_tizenapi/tizen_lifecycle.cpp +++ b/probe_tizenapi/tizen_lifecycle.cpp @@ -41,11 +41,6 @@ #include "tizen_probe.h" #include "binproto.h" -extern "C" -{ -Ecore_Event_Handler* register_orientation_event_listener(); -void unregister_orientation_event_listener(Ecore_Event_Handler* handler); -} using namespace Tizen::Base; using namespace Tizen::Base::Collection; @@ -85,13 +80,11 @@ result UiApp::Execute(UiAppInstanceFactory pUiAppFactory, static methodType uiapp_executep; probeInfo_t probeInfo; unsigned long __attribute__((unused)) ret; - Ecore_Event_Handler* handler; GET_REAL_FUNC_TIZEN(_ZN5Tizen3App5UiApp7ExecuteEPFPS1_vEPKNS_4Base10Collection5IListE, LIBOSP_UIFW, uiapp_executep); probeBlockStart(); - handler = register_orientation_event_listener(); if(gTraceInfo.exec_map.map_start == NULL) { get_map_address(CALLER_ADDRESS, &(gTraceInfo.exec_map.map_start), @@ -112,7 +105,6 @@ result UiApp::Execute(UiAppInstanceFactory pUiAppFactory, PACK_COMMON_END('x', ret, 0, 0); FLUSH_LOCAL_BUF(); - unregister_orientation_event_listener(handler); probeBlockEnd(); return ret; -- 2.7.4