[input] Add safety checks before accessing Cursor of focused pointer

There might be no focused pointer and there might be no cursor.
This commit is contained in:
Martin Gräßlin 2015-03-04 08:04:46 +01:00
parent 92d06a8c4b
commit e8b14cd587

View file

@ -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);