From 3a2b3fc0d72fe1e52a7830e03f849963f6b73e02 Mon Sep 17 00:00:00 2001 From: Gatis Paeglis Date: Wed, 23 Jan 2013 15:45:52 +0100 Subject: Don't try to render a pixmap when there isn't any. This happened in cases when QDrag choose not to use a pixmap to represent data in a drag and drop operation. The chain that leads to QPainter errors begins in QBasicDrag::startDrag() where we call setPixmap() with Null pixmap, which later calls updateGeometry() which leads to calling render() before the backing store has been resized. Task-number: QTBUG-29283 Change-Id: I2145159d3f23dbde2cba2ca9aa1788e222aba02a Reviewed-by: Friedemann Kleint --- src/platformsupport/dnd/qshapedpixmapdndwindow.cpp | 4 +++- src/platformsupport/dnd/qsimpledrag.cpp | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/platformsupport/dnd/qshapedpixmapdndwindow.cpp b/src/platformsupport/dnd/qshapedpixmapdndwindow.cpp index 67c3cb4701..b3e64b01d0 100644 --- a/src/platformsupport/dnd/qshapedpixmapdndwindow.cpp +++ b/src/platformsupport/dnd/qshapedpixmapdndwindow.cpp @@ -91,7 +91,9 @@ void QShapedPixmapWindow::setHotspot(const QPoint &hotspot) void QShapedPixmapWindow::updateGeometry() { QRect rect(QCursor::pos() - m_hotSpot, m_pixmap.size()); - if (m_backingStore->size() != m_pixmap.size()) + if (m_pixmap.isNull()) + m_backingStore->resize(QSize(1,1)); + else if (m_backingStore->size() != m_pixmap.size()) m_backingStore->resize(m_pixmap.size()); setGeometry(rect); } diff --git a/src/platformsupport/dnd/qsimpledrag.cpp b/src/platformsupport/dnd/qsimpledrag.cpp index 3b73380cab..fe0146afc3 100644 --- a/src/platformsupport/dnd/qsimpledrag.cpp +++ b/src/platformsupport/dnd/qsimpledrag.cpp @@ -207,6 +207,8 @@ void QBasicDrag::resetDndState(bool /* deleteSource */) void QBasicDrag::startDrag() { + // ### TODO Check if its really necessary to have m_drag_icon_window + // when QDrag is used without a pixmap - QDrag::setPixmap() if (!m_drag_icon_window) m_drag_icon_window = new QShapedPixmapWindow(); -- cgit v1.2.3