Set mKeyMap before registering for ECORE_EVENT_KEY_DOWN, ECORE_EVENT_KEY_UP events. 12/297212/2
authorjoogab.yun <joogab.yun@samsung.com>
Mon, 14 Aug 2023 02:35:14 +0000 (11:35 +0900)
committerjoogab.yun <joogab.yun@samsung.com>
Mon, 14 Aug 2023 04:31:56 +0000 (13:31 +0900)
If the keyEvent happens before mKeyMap is set, it crashes because mKeyMap is null.

0  __GI_raise (sig=11) at /usr/src/debug/glibc-2.30-1.11.arm/signal/../sysdeps/unix/sysv/linux/raise.c:50
1  0xb3d8bb12 in invoke_previous_action (action=<optimized out>, code=11, siginfo=0xb4779c88, context=0xb4779d08, signalRestarts=255) at /usr/src/debug/coreclr-6.0.9-1.arm/src/coreclr/pal/src/exception/signal.cpp:415
2  sigsegv_handler (code=11, siginfo=0xb4779c88, context=<optimized out>) at /usr/src/debug/coreclr-6.0.9-1.arm/src/coreclr/pal/src/exception/signal.cpp:627
3  <signal handler called>
4  0xab9b7c04 in xkb_keymap_key_for_each (keymap=0x0, iter=0xa6d4ec55 <Dali::Internal::Adaptor::(anonymous namespace)::FindKeyCode(xkb_keymap*, xkb_keycode_t, void*)>, data=data@entry=0xbe0f56b0) at /usr/src/debug/libxkbcommon-1.5.0-0.arm/builddir/../src/keymap.c:531
5  0xa6d508a0 in Dali::Internal::Adaptor::WindowBaseEcoreWl2::GetKeyCode (this=0x21f37b0, keyName=..., keyCode=@0xbe0f5754: 0) at /usr/src/debug/dali2-adaptor-2.2.37-1.arm/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp:1686
6  0xa6d11f60 in Dali::Internal::Adaptor::WindowBaseEcoreWl2::OnKeyDown(void*, int, void*) [clone .constprop.0] (this=0x21f37b0, event=0x2522e40, type=<optimized out>, data=<optimized out>) at /usr/src/debug/dali2-adaptor-2.2.37-1.arm/dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp:1402

Change-Id: I0aaf2791e5daa464e81acafbcb53532046381aee

dali/internal/window-system/tizen-wayland/ecore-wl2/window-base-ecore-wl2.cpp

index 7dd0015..0e0c74f 100644 (file)
@@ -948,6 +948,16 @@ void WindowBaseEcoreWl2::Initialize(PositionSize positionSize, Any surface, bool
 
   SetTransparency(isTransparent);
 
+  Ecore_Wl2_Display* display      = ecore_wl2_connected_display_get(NULL);
+  Ecore_Wl2_Input*   ecoreWlInput = ecore_wl2_input_default_input_get(display);
+
+  if(ecoreWlInput)
+  {
+    mKeyMap = ecore_wl2_input_keymap_get(ecoreWlInput);
+
+    mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_KEYMAP_CHANGED, EcoreEventSeatKeymapChanged, this));
+  }
+
   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_ICONIFY_STATE_CHANGE, EcoreEventWindowIconifyStateChanged, this));
   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_IN, EcoreEventWindowFocusIn, this));
   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_FOCUS_OUT, EcoreEventWindowFocusOut, this));
@@ -1010,9 +1020,7 @@ void WindowBaseEcoreWl2::Initialize(PositionSize positionSize, Any surface, bool
   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_INTERACTIVE_MOVE_DONE, EcoreEventWindowMoveCompleted, this));
   mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_WINDOW_INTERACTIVE_RESIZE_DONE, EcoreEventWindowResizeCompleted, this));
 
-  Ecore_Wl2_Display* display = ecore_wl2_connected_display_get(NULL);
-  mDisplay                   = ecore_wl2_display_get(display);
-
+  mDisplay = ecore_wl2_display_get(display);
   if(mDisplay)
   {
     wl_display* displayWrapper = static_cast<wl_display*>(wl_proxy_create_wrapper(mDisplay));
@@ -1034,15 +1042,6 @@ void WindowBaseEcoreWl2::Initialize(PositionSize positionSize, Any surface, bool
     }
   }
 
-  Ecore_Wl2_Input* ecoreWlInput = ecore_wl2_input_default_input_get(display);
-
-  if(ecoreWlInput)
-  {
-    mKeyMap = ecore_wl2_input_keymap_get(ecoreWlInput);
-
-    mEcoreEventHandler.PushBack(ecore_event_handler_add(ECORE_WL2_EVENT_SEAT_KEYMAP_CHANGED, EcoreEventSeatKeymapChanged, this));
-  }
-
   // get auxiliary hint
   Eina_List* hints = ecore_wl2_window_aux_hints_supported_get(mEcoreWindow);
   if(hints)
@@ -1603,7 +1602,7 @@ void WindowBaseEcoreWl2::OnEcoreEventConformantChange(void* event)
     int w = 0;
     int h = 0;
 
-    switch (ev->part_type)
+    switch(ev->part_type)
     {
       case ECORE_WL2_INDICATOR_PART:
       {
@@ -1631,9 +1630,9 @@ void WindowBaseEcoreWl2::OnEcoreEventConformantChange(void* event)
 
     WindowInsetsPartState partState = WindowInsetsPartState::INVISIBLE;
 
-    int left = 0;
-    int right = 0;
-    int top = 0;
+    int left   = 0;
+    int right  = 0;
+    int top    = 0;
     int bottom = 0;
 
     // Insets are applied only if system UI(e.g. virtual keyboard) satisfies the following 2 conditions.
@@ -1660,12 +1659,12 @@ void WindowBaseEcoreWl2::OnEcoreEventConformantChange(void* event)
       {
         if((y <= winY) && (y + h >= winY) && (y + h <= winY + winH))
         {
-          top = y + h - winY;
+          top         = y + h - winY;
           applyInsets = true;
         }
         else if((y + h >= winY + winH) && (y >= winY) && (y <= winY + winH))
         {
-          bottom = winY + winH - y;
+          bottom      = winY + winH - y;
           applyInsets = true;
         }
       }
@@ -1673,12 +1672,12 @@ void WindowBaseEcoreWl2::OnEcoreEventConformantChange(void* event)
       {
         if((x <= winX) && (x + w >= winX) && (x + w <= winX + winW))
         {
-          left = x + w - winX;
+          left        = x + w - winX;
           applyInsets = true;
         }
         else if((x + w >= winX + winW) && (x >= winX) && (x <= winX + winW))
         {
-          right = winX + winW - x;
+          right       = winX + winW - x;
           applyInsets = true;
         }
       }
@@ -1768,7 +1767,7 @@ void WindowBaseEcoreWl2::RegistryGlobalCallbackRemove(void* data, struct wl_regi
 
 void WindowBaseEcoreWl2::TizenPolicyConformantArea(void* data, struct tizen_policy* tizenPolicy, struct wl_surface* surface, uint32_t conformantPart, uint32_t state, int32_t x, int32_t y, int32_t w, int32_t h)
 {
-  int originalX, originalY, originalWidth, originalHeight;
+  int  originalX, originalY, originalWidth, originalHeight;
   bool changed = false;
 
   if(!surface)
@@ -1790,7 +1789,7 @@ void WindowBaseEcoreWl2::TizenPolicyConformantArea(void* data, struct tizen_poli
      * The given state is based on the visibility value of indicator.
      * Thus we need to add 1 to it before comparing with indicator state.
      */
-    Ecore_Wl2_Indicator_State indState =  ecore_wl2_window_indicator_state_get(mEcoreWindow);
+    Ecore_Wl2_Indicator_State indState = ecore_wl2_window_indicator_state_get(mEcoreWindow);
     if((state + 1) != indState)
     {
       ecore_wl2_window_indicator_state_set(mEcoreWindow, static_cast<Ecore_Wl2_Indicator_State>(state + 1));
@@ -1840,15 +1839,15 @@ void WindowBaseEcoreWl2::TizenPolicyConformantArea(void* data, struct tizen_poli
 
   if(changed)
   {
-    Ecore_Wl2_Event_Conformant_Change *ev = static_cast<Ecore_Wl2_Event_Conformant_Change*>(calloc(1, sizeof(Ecore_Wl2_Event_Conformant_Change)));
+    Ecore_Wl2_Event_Conformant_Changeev = static_cast<Ecore_Wl2_Event_Conformant_Change*>(calloc(1, sizeof(Ecore_Wl2_Event_Conformant_Change)));
 
     if(!ev)
     {
       return;
     }
-    ev->win = GetNativeWindowId();
+    ev->win       = GetNativeWindowId();
     ev->part_type = static_cast<Ecore_Wl2_Conformant_Part_Type>(conformantPart);
-    ev->state = state;
+    ev->state     = state;
     ecore_event_add(ECORE_WL2_EVENT_CONFORMANT_CHANGE, ev, NULL, NULL);
   }