From 003060e2928209b8028fa176b6c8b19777f1617b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Samuel=20R=C3=B8dal?= Date: Mon, 19 Sep 2011 13:42:20 +0200 Subject: [PATCH] Make sure to clip in QXcbBackingStore::flush() Clip to image and window dimensions to prevent X errors. Change-Id: I7fa581217444e00d6eb83ac356c600f86ae03636 Reviewed-on: http://codereview.qt-project.org/5140 Reviewed-by: Qt Sanity Bot Reviewed-by: Holger Ihrig --- src/plugins/platforms/xcb/qxcbbackingstore.cpp | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/src/plugins/platforms/xcb/qxcbbackingstore.cpp b/src/plugins/platforms/xcb/qxcbbackingstore.cpp index fadcb4d5b8..df6cf318bb 100644 --- a/src/plugins/platforms/xcb/qxcbbackingstore.cpp +++ b/src/plugins/platforms/xcb/qxcbbackingstore.cpp @@ -251,16 +251,25 @@ void QXcbBackingStore::endPaint(const QRegion &) void QXcbBackingStore::flush(QWindow *window, const QRegion ®ion, const QPoint &offset) { - QRect bounds = region.boundingRect(); - if (!m_image || m_image->size().isEmpty()) return; + QSize imageSize = m_image->size(); + + QRegion clipped = region; + clipped &= QRect(0, 0, window->width(), window->height()); + clipped &= QRect(0, 0, imageSize.width(), imageSize.height()).translated(-offset); + + QRect bounds = clipped.boundingRect(); + + if (bounds.isNull()) + return; + Q_XCB_NOOP(connection()); QXcbWindow *platformWindow = static_cast(window->handle()); - QVector rects = region.rects(); + QVector rects = clipped.rects(); for (int i = 0; i < rects.size(); ++i) m_image->put(platformWindow->xcb_window(), rects.at(i).topLeft(), rects.at(i).translated(offset));