Client: Don't crash when the cursor theme fails to load

Fixes: QTBUG-75920
Change-Id: I29d84b487afb2a90b8a633abce2fcc39ca75adae
Reviewed-by: Paul Olav Tvete <paul.tvete@qt.io>
Reviewed-by: Jani Heikkinen <jani.heikkinen@qt.io>
This commit is contained in:
Johan Klokkhammer Helsing 2019-05-21 09:06:30 +02:00
parent 3eb4e7ca76
commit 84c3fcffd9

View File

@ -272,6 +272,10 @@ void QWaylandInputDevice::Pointer::updateCursorTheme()
int pixelSize = cursorSize() * scale; int pixelSize = cursorSize() * scale;
auto *display = seat()->mQDisplay; auto *display = seat()->mQDisplay;
mCursor.theme = display->loadCursorTheme(cursorThemeName(), pixelSize); mCursor.theme = display->loadCursorTheme(cursorThemeName(), pixelSize);
if (!mCursor.theme)
return; // A warning has already been printed in loadCursorTheme
if (auto *arrow = mCursor.theme->cursorImage(Qt::ArrowCursor)) { if (auto *arrow = mCursor.theme->cursorImage(Qt::ArrowCursor)) {
int arrowPixelSize = qMax(arrow->width, arrow->height); // Not all cursor themes are square int arrowPixelSize = qMax(arrow->width, arrow->height); // Not all cursor themes are square
while (scale > 1 && arrowPixelSize / scale < cursorSize()) while (scale > 1 && arrowPixelSize / scale < cursorSize())
@ -310,6 +314,9 @@ void QWaylandInputDevice::Pointer::updateCursor()
if (!mCursor.theme || idealCursorScale() != mCursor.themeBufferScale) if (!mCursor.theme || idealCursorScale() != mCursor.themeBufferScale)
updateCursorTheme(); updateCursorTheme();
if (!mCursor.theme)
return;
// Set from shape using theme // Set from shape using theme
if (struct ::wl_cursor_image *image = mCursor.theme->cursorImage(shape)) { if (struct ::wl_cursor_image *image = mCursor.theme->cursorImage(shape)) {
struct wl_buffer *buffer = wl_cursor_image_get_buffer(image); struct wl_buffer *buffer = wl_cursor_image_get_buffer(image);