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>
This commit is contained in:
parent
fe4068a12b
commit
d998469740
@ -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
|
||||
|
@ -56,7 +56,7 @@ public:
|
||||
QPoint pos() const;
|
||||
void setPos(const QPoint &pos);
|
||||
|
||||
static void queryPointer(xcb_connection_t *conn, xcb_window_t *rootWin, QPoint *pos, int *keybMask = 0);
|
||||
static void queryPointer(QXcbConnection *c, xcb_window_t *rootWin, QPoint *pos, int *keybMask = 0);
|
||||
|
||||
private:
|
||||
xcb_cursor_t createFontCursor(int cshape);
|
||||
|
@ -275,8 +275,8 @@ QPlatformServices *QXcbIntegration::services() const
|
||||
Qt::KeyboardModifiers QXcbIntegration::queryKeyboardModifiers() const
|
||||
{
|
||||
int keybMask = 0;
|
||||
QXcbConnection* conn = m_connections.at(0);
|
||||
QXcbCursor::queryPointer(conn->xcb_connection(), 0, 0, &keybMask);
|
||||
QXcbConnection *conn = m_connections.at(0);
|
||||
QXcbCursor::queryPointer(conn, 0, 0, &keybMask);
|
||||
return conn->keyboard()->translateModifiers(keybMask);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user