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

QGraphicsView::setViewport() flaw when used in event handler

    XMLWordPrintable

Details

    Description

      Situation: QGraphicsView subclass which uses a context popup menu. One of the menus is "Toggle OpenGL Mode" (like the GL button in the "40000 chips" example in the qt tree). When the menu it triggered, the View item calls this->setViewport() to set a new QGLWidget or QWidget (depending on the toggle). That causes a warning from Qt:

      QObject: Do not delete object, 'QBoardViewViewport', during its event handler!

      What's happening is that the setViewport() call is deleting the previous viewport, which is fine and expected. But the popup menu event which triggered the whole thing actually comes in response to the viewport events, not the View itself. Thus the stepping-on-self.

      Perhaps changing QAbstractScrollArea::setViewport() a bit might fix it, so instead of:

      delete oldViewport;

      do:

      if ( oldViewport ) oldViewport->deleteLater();

      Attachments

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

        Activity

          People

            hanssen Andreas Aardal Hanssen (closed Nokia identity) (Inactive)
            admin Administrator
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes