From e8b14cd5877131f416887f2e1862330c69a8e5e7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Martin=20Gr=C3=A4=C3=9Flin?= Date: Wed, 4 Mar 2015 08:04:46 +0100 Subject: [PATCH] [input] Add safety checks before accessing Cursor of focused pointer There might be no focused pointer and there might be no cursor. --- input.cpp | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/input.cpp b/input.cpp index cee573a46b..cb9902ca9a 100644 --- a/input.cpp +++ b/input.cpp @@ -341,7 +341,11 @@ void InputRedirection::updatePointerWindow() if (oldWindow) { disconnect(oldWindow.data(), &Toplevel::geometryChanged, this, &InputRedirection::updateFocusedPointerPosition); if (AbstractBackend *b = waylandServer()->backend()) { - disconnect(seat->focusedPointer()->cursor(), &KWayland::Server::Cursor::changed, b, &AbstractBackend::installCursorFromServer); + if (auto p = seat->focusedPointer()) { + if (auto c = p->cursor()) { + disconnect(c, &KWayland::Server::Cursor::changed, b, &AbstractBackend::installCursorFromServer); + } + } } } if (t && t->surface()) { @@ -349,7 +353,11 @@ void InputRedirection::updatePointerWindow() connect(t, &Toplevel::geometryChanged, this, &InputRedirection::updateFocusedPointerPosition); if (AbstractBackend *b = waylandServer()->backend()) { b->installCursorFromServer(); - connect(seat->focusedPointer()->cursor(), &KWayland::Server::Cursor::changed, b, &AbstractBackend::installCursorFromServer); + if (auto p = seat->focusedPointer()) { + if (auto c = p->cursor()) { + connect(c, &KWayland::Server::Cursor::changed, b, &AbstractBackend::installCursorFromServer); + } + } } } else { seat->setFocusedPointerSurface(nullptr);