From 04a4b999023268d91575be50bd8d78d3f0ef0213 Mon Sep 17 00:00:00 2001 From: Uli Schlachter Date: Sun, 22 Jan 2012 20:41:42 +0100 Subject: [PATCH] xcb: Don't crash on missing mouse pointer MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The draganddrop examples all crashed here because they were using a default-constructed QImage() (i.e. one without any content). I guess this happens here because I don't have any mouse theme set. To test, one could start a second X server, but without any WM or DE. The "evil" QImage() came from QGuiApplicationPrivate::getPixmapCursor(). This function seems to just always "return QPixmap();". This fix is correct because the only caller has another fallback if the createNonStandardCursor()-fallback didn't work. This caller is QXcbCursor::createFontCursor(). Change-Id: I7ec7fbcfdf0203e983149b5e73016cc7e85ecf40 Signed-off-by: Uli Schlachter Reviewed-by: Samuel Rødal --- src/plugins/platforms/xcb/qxcbcursor.cpp | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbcursor.cpp b/src/plugins/platforms/xcb/qxcbcursor.cpp index b92c00a2fe..ac6825a004 100644 --- a/src/plugins/platforms/xcb/qxcbcursor.cpp +++ b/src/plugins/platforms/xcb/qxcbcursor.cpp @@ -426,10 +426,12 @@ xcb_cursor_t QXcbCursor::createNonStandardCursor(int cshape) } else if (cshape == Qt::DragCopyCursor || cshape == Qt::DragMoveCursor || cshape == Qt::DragLinkCursor) { QImage image = QGuiApplicationPrivate::instance()->getPixmapCursor(static_cast(cshape)).toImage(); - xcb_pixmap_t pm = qt_xcb_XPixmapFromBitmap(m_screen, image); - xcb_pixmap_t pmm = qt_xcb_XPixmapFromBitmap(m_screen, image.createAlphaMask()); - cursor = xcb_generate_id(conn); - xcb_create_cursor(conn, cursor, pm, pmm, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 8, 8); + if (!image.isNull()) { + xcb_pixmap_t pm = qt_xcb_XPixmapFromBitmap(m_screen, image); + xcb_pixmap_t pmm = qt_xcb_XPixmapFromBitmap(m_screen, image.createAlphaMask()); + cursor = xcb_generate_id(conn); + xcb_create_cursor(conn, cursor, pm, pmm, 0, 0, 0, 0xFFFF, 0xFFFF, 0xFFFF, 8, 8); + } } return cursor;