diff options
author | Uli Schlachter <psychon@znc.in> | 2012-01-22 20:41:42 +0100 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-01-23 11:02:18 +0100 |
commit | 04a4b999023268d91575be50bd8d78d3f0ef0213 (patch) | |
tree | 22489e4348caaf91032ba1eaec6a83af01b2717e /src/plugins/platforms/xcb/qxcbcursor.cpp | |
parent | 27df9a5a9761eebb609d59a78a0d9475873c06de (diff) |
xcb: Don't crash on missing mouse pointer
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 <psychon@znc.in>
Reviewed-by: Samuel Rødal <samuel.rodal@nokia.com>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbcursor.cpp')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbcursor.cpp | 10 |
1 files 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<Qt::CursorShape>(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; |