From: Sung-Jin Park Date: Tue, 18 Aug 2020 05:32:46 +0000 (+0900) Subject: DSWaylandKeyboard: fix to initialze member variable properly, add exception handling... X-Git-Tag: accepted/tizen/unified/20200820.213435~37 X-Git-Url: http://review.tizen.org/git/?a=commitdiff_plain;h=refs%2Fchanges%2F38%2F241838%2F1;p=platform%2Fcore%2Fuifw%2Flibds.git DSWaylandKeyboard: fix to initialze member variable properly, add exception handling on setFocus() Change-Id: I20211a9be278d73bd21baacb230704f347711040 Signed-off-by: Sung-Jin Park --- diff --git a/src/DSWaylandServer/DSWaylandKeyboard.cpp b/src/DSWaylandServer/DSWaylandKeyboard.cpp index 85fa455..48ce7f4 100644 --- a/src/DSWaylandServer/DSWaylandKeyboard.cpp +++ b/src/DSWaylandServer/DSWaylandKeyboard.cpp @@ -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()); + } } }