diff options
author | Samuel Rødal <samuel.rodal@digia.com> | 2012-10-23 17:19:29 +0200 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-10-26 22:39:39 +0200 |
commit | d9984697401460c64d1a49838b61a298f291b9dd (patch) | |
tree | 3ce0bb7d87cec3c2a481e713f9dd0f6e19dd4dc9 /src/plugins/platforms/xcb/qxcbcursor.cpp | |
parent | fe4068a12b135add4e1203fc1214d238865b49a1 (diff) |
Prevent potential crash in QXcbCursor::queryPointer().
xcb_get_setup might return 0, but we already have it in QXcbConnection.
Task-number: QTBUG-27686
Change-Id: I58418aedd6bc121ae2b9605389beb3f6612d7fb7
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@digia.com>
Reviewed-by: Shawn Rutledge <shawn.rutledge@digia.com>
Reviewed-by: Gatis Paeglis <gatis.paeglis@digia.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Diffstat (limited to 'src/plugins/platforms/xcb/qxcbcursor.cpp')
-rw-r--r-- | src/plugins/platforms/xcb/qxcbcursor.cpp | 17 |
1 files changed, 8 insertions, 9 deletions
diff --git a/src/plugins/platforms/xcb/qxcbcursor.cpp b/src/plugins/platforms/xcb/qxcbcursor.cpp index 0510c1db5b..c1cfbd02d6 100644 --- a/src/plugins/platforms/xcb/qxcbcursor.cpp +++ b/src/plugins/platforms/xcb/qxcbcursor.cpp @@ -508,16 +508,16 @@ xcb_cursor_t QXcbCursor::createBitmapCursor(QCursor *cursor) return c; } -void QXcbCursor::queryPointer(xcb_connection_t *conn, xcb_window_t *rootWin, QPoint *pos, int *keybMask) +void QXcbCursor::queryPointer(QXcbConnection *c, xcb_window_t *rootWin, QPoint *pos, int *keybMask) { if (pos) *pos = QPoint(); - xcb_screen_iterator_t it = xcb_setup_roots_iterator(xcb_get_setup(conn)); + xcb_screen_iterator_t it = xcb_setup_roots_iterator(c->setup()); while (it.rem) { xcb_window_t root = it.data->root; - xcb_query_pointer_cookie_t cookie = xcb_query_pointer(conn, root); + xcb_query_pointer_cookie_t cookie = xcb_query_pointer(c->xcb_connection(), root); xcb_generic_error_t *err = 0; - xcb_query_pointer_reply_t *reply = xcb_query_pointer_reply(conn, cookie, &err); + xcb_query_pointer_reply_t *reply = xcb_query_pointer_reply(c->xcb_connection(), cookie, &err); if (!err && reply) { if (pos) *pos = QPoint(reply->root_x, reply->root_y); @@ -537,17 +537,16 @@ void QXcbCursor::queryPointer(xcb_connection_t *conn, xcb_window_t *rootWin, QPo QPoint QXcbCursor::pos() const { QPoint p; - queryPointer(xcb_connection(), 0, &p); + queryPointer(connection(), 0, &p); return p; } void QXcbCursor::setPos(const QPoint &pos) { - xcb_connection_t *conn = xcb_connection(); xcb_window_t root; - queryPointer(conn, &root, 0); - xcb_warp_pointer(conn, XCB_NONE, root, 0, 0, 0, 0, pos.x(), pos.y()); - xcb_flush(conn); + queryPointer(connection(), &root, 0); + xcb_warp_pointer(xcb_connection(), XCB_NONE, root, 0, 0, 0, 0, pos.x(), pos.y()); + xcb_flush(xcb_connection()); } QT_END_NAMESPACE |