DSWaylandKeyboard: fix to initialze member variable properly, add exception handling... 38/241838/1
authorSung-Jin Park <sj76.park@samsung.com>
Tue, 18 Aug 2020 05:32:46 +0000 (14:32 +0900)
committerSung-Jin Park <sj76.park@samsung.com>
Thu, 20 Aug 2020 10:11:57 +0000 (19:11 +0900)
Change-Id: I20211a9be278d73bd21baacb230704f347711040
Signed-off-by: Sung-Jin Park <sj76.park@samsung.com>
src/DSWaylandServer/DSWaylandKeyboard.cpp

index 85fa455..48ce7f4 100644 (file)
@@ -39,8 +39,8 @@ DSWaylandKeyboardPrivate::DSWaylandKeyboardPrivate(DSWaylandSeat *seat, DSWaylan
        : DSObjectPrivate(keyboard),
          __p_ptr(keyboard),
          __seat(seat),
-         __xkb(seat->getXkb()),
-         __compositor(seat->getCompositor()),
+         __xkb(seat ? (seat->getXkb()) : nullptr),
+         __compositor(seat ? (seat->getCompositor()) : nullptr),
          __focusSurface(nullptr),
          __focusClient(nullptr),
          __repeatRate(0),
@@ -267,18 +267,21 @@ void DSWaylandKeyboard::setFocus(DSWaylandSurface *waylandSurface)
 
        if (priv->__focusSurface != waylandSurface)
        {
-               if (priv->__focusSurface)
+               if (priv->__focusSurface && priv->__focusSurface->hasResource())
                {
                        struct ::wl_resource *surfaceToLeave = priv->__focusSurface->getWlResource();
                        priv->sendModifiers(surfaceToLeave);
                        priv->sendLeave(surfaceToLeave);
                }
 
-               struct ::wl_resource *surfaceToEnter = waylandSurface->getWlResource();
-               priv->sendEnter(surfaceToEnter);
+               if (waylandSurface && waylandSurface->hasResource())
+               {
+                       struct ::wl_resource *surfaceToEnter = waylandSurface->getWlResource();
+                       priv->sendEnter(surfaceToEnter);
 
-               priv->__focusSurface = waylandSurface;
-               priv->__focusClient = wl_resource_get_client(waylandSurface->getWlResource());
+                       priv->__focusSurface = waylandSurface;
+                       priv->__focusClient = wl_resource_get_client(waylandSurface->getWlResource());
+               }
        }
 }