[FIX] internet application crash 90/13990/5
authorVitaliy Cherepanov <v.cherepanov@samsung.com>
Thu, 19 Dec 2013 16:00:00 +0000 (20:00 +0400)
committerVitaliy Cherepanov <v.cherepanov@samsung.com>
Fri, 20 Dec 2013 11:38:07 +0000 (15:38 +0400)
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 <v.cherepanov@samsung.com>
probe_event/da_event.c
probe_event/orientation.c
probe_tizenapi/tizen_lifecycle.cpp

index b62eef0..e0476d8 100755 (executable)
@@ -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();
 }
index 3c080d0..3dfe953 100644 (file)
 #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_MessagepClientEvent;
+       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_Handlerregister_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_Handlerhandler)
+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();
 }
index 5fd5525..86007b0 100755 (executable)
 #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;