Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. QGraphicsView crash
Qt 6.11 is out! See what's new in the release blog

QGraphicsView crash

Scheduled Pinned Locked Moved Unsolved General and Desktop
3 Posts 3 Posters 392 Views
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • W Offline
    W Offline
    WENGSHIYING
    wrote on last edited by
    #1

    I have a control that inherits from QGraphicsView. After the control loads an image, exit the program will have an exception: 0x00007FFA3E98C501 (d2d1.dll) : 0xC0000005:

    the code is simple:
    m_Scene.setBackgroundBrush(QBrush(Qt::blue));
    m_Scene.addItem(&m_ImageItem);
    setScene(&m_Scene);

    JonBJ 1 Reply Last reply
    0
    • W WENGSHIYING

      I have a control that inherits from QGraphicsView. After the control loads an image, exit the program will have an exception: 0x00007FFA3E98C501 (d2d1.dll) : 0xC0000005:

      the code is simple:
      m_Scene.setBackgroundBrush(QBrush(Qt::blue));
      m_Scene.addItem(&m_ImageItem);
      setScene(&m_Scene);

      JonBJ Online
      JonBJ Online
      JonB
      wrote on last edited by
      #2

      @WENGSHIYING
      You should run it under debugger, allow it to crash, and look at the stack trace pane.

      m_Scene.addItem(&m_ImageItem);

      Check the scope/lifetime of m_ImageItem. It is unusual to add an item from the stack, try allocating it on the heap? And also check what is in m_ImageItem, is it valid?

      JoeCFDJ 1 Reply Last reply
      4
      • JonBJ JonB

        @WENGSHIYING
        You should run it under debugger, allow it to crash, and look at the stack trace pane.

        m_Scene.addItem(&m_ImageItem);

        Check the scope/lifetime of m_ImageItem. It is unusual to add an item from the stack, try allocating it on the heap? And also check what is in m_ImageItem, is it valid?

        JoeCFDJ Offline
        JoeCFDJ Offline
        JoeCFD
        wrote on last edited by
        #3

        @JonB
        Jon has a good point. Check here out
        https://doc.qt.io/qt-5.15/qgraphicsscene.html#addItem
        void QGraphicsScene::addItem(QGraphicsItem *item)
        Adds or moves the item and all its children to this scene. This scene takes ownership of the item.

        m_ImageItem has to be a pointer created on Heap.

        1 Reply Last reply
        4

        • Login

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved