Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-35385

processing GeometryChangeEvent during paint causes QPaintDevice invalidation and crash

    XMLWordPrintable

Details

    • Bug
    • Resolution: Incomplete
    • P1: Critical
    • None
    • 5.1.0 , 5.1.1
    • GUI: Painting
    • None
    • Windows 7 64 Bit, Qt::AA_NativeWindows is true

    Description

      I have a QMainWindow with QDockWidgets. One Dock contains a QTreeWidget, the other a data entry form. The user select objects, which causes an update in the QTreeWidget as well as an update in the data entry form. What happens sporadically (hard to reproduce) is that, during the update, the repaint event also processes a resize event. This resize event unfortunately invalidates the CImage inside the QWindowsBackingStore used for the repaint. This invalidated CImage has already been passed deeply into a call chain, causing an access vialoation when used next time in QPainter::begin.

      The invalidation happens in QWindowsBackingStore::resize (qwindowsbackingstore.cpp::150)

      m_image.reset(new QWindowsNativeImage(size.width(), size.height(), format));

      It is not necessary at this point to throw away the CImage every time here, but simply implement a new method QWindowsNativeImage::resize which works like the constructor. A positive side effect is avoiding a heap allocation. I have attached a patch file with those changes.

      This is the call stack:

      ntdll.dll!_KiUserExceptionDispatcher@8 Unknown
      Qt5Gui.dll!QPainter::begin Line 1733 C++
      Qt5Gui.dll!QPainter::QPainter Line 1474 C++
      Qt5Widgets.dll!QAbstractScrollArea::event Line 992 C++
      Qt5Widgets.dll!QAbstractItemView::event Line 1612 C++
      Qt5Widgets.dll!QTreeWidget::event Line 3429 C++
      Qt5Widgets.dll!QApplicationPrivate::notify_helper Line 3456 C++
      Qt5Widgets.dll!QApplication::notify Line 3420 C++
      ...
      Qt5Core.dll!QCoreApplication::sendSpontaneousEvent Line 235 C++
      Qt5Widgets.dll!QWidgetPrivate::drawWidget Line 5130 C++
      Qt5Widgets.dll!QWidgetPrivate::paintSiblingsRecursive Line 5325 C++
      Qt5Widgets.dll!QWidgetPrivate::drawWidget Line 5183 C++
      Qt5Widgets.dll!QWidgetPrivate::paintSiblingsRecursive Line 5325 C++
      Qt5Widgets.dll!QWidgetPrivate::paintSiblingsRecursive Line 5312 C++
      Qt5Widgets.dll!QWidgetPrivate::paintSiblingsRecursive Line 5312 C++
      Qt5Widgets.dll!QWidgetPrivate::paintSiblingsRecursive Line 5312 C++
      Qt5Widgets.dll!QWidgetPrivate::paintSiblingsRecursive Line 5312 C++
      Qt5Widgets.dll!QWidgetPrivate::paintSiblingsRecursive Line 5312 C++
      Qt5Widgets.dll!QWidgetPrivate::paintSiblingsRecursive Line 5312 C++
      Qt5Widgets.dll!QWidgetPrivate::drawWidget Line 5183 C++
      Qt5Widgets.dll!QWidgetBackingStore::sync Line 1093 C++
      Qt5Widgets.dll!QWidgetWindow::handleResizeEvent Line 537 C++
      Qt5Widgets.dll!QWidgetWindow::event Line 180 C++
      Qt5Widgets.dll!QApplicationPrivate::notify_helper Line 3456 C++
      Qt5Widgets.dll!QApplication::notify Line 3420 C++
      ...
      Qt5Core.dll!QCoreApplication::sendSpontaneousEvent Line 235 C++
      Qt5Gui.dll!QGuiApplicationPrivate::processGeometryChangeEvent Line 1725 C++
      Qt5Gui.dll!QGuiApplicationPrivate::processWindowSystemEvent Line 1274 C++
      Qt5Gui.dll!QWindowSystemInterface::sendWindowSystemEventsImplementation Line 582 C++
      Qt5Gui.dll!QWindowSystemInterface::flushWindowSystemEvents Line 554 C++
      qwindows.dll!QWindowsWindow::handleWmPaint Line 1327 C++
      qwindows.dll!QWindowsContext::windowsProc Line 870 C++
      qwindows.dll!qWindowsWndProc Line 952 C++
      

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            kleint Friedemann Kleint
            jam Jakob Magiera
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes