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

Memory Leak when QQuickItem created by QQmlComponent in C++

    XMLWordPrintable

Details

    • Linux/X11, Windows

    Description

      Hi, 

      I tried to create and delete QQuickItem from C++.  but I found there is memory leak when  I call QuickItem deleteLater function.

      You can check the simple attachment.

      here is simple code show create quickitem in C++: 

       QQmlComponent component(m_pQMLEngine, "qrc:/Test.qml", this);
          if(component.isReady()) {
             m_tmpItem = qobject_cast<QQuickItem*>(component.create(m_pQMLContext));
              m_tmpItem->setParentItem(m_pMainRootItem);
              m_tmpItem->setX(100);

              // QQmlApplicationEngine::setObjectOwnership(m_tmpItem, QQmlApplicationEngine::JavaScriptOwnership);
              QQmlApplicationEngine::setObjectOwnership(m_tmpItem, QQmlApplicationEngine::CppOwnership);
              QObject::connect(m_tmpItem, &QObject::destroyed, [&]()

      {             qDebug()<<"destroyed!!!!!";         }

      );
          } else

      {         qCritical()<<"create EffectPage failed"<<component.errors();     }

      Attachments

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

        Activity

          People

            qtqmlteam Qt Qml Team User
            haipeng.yu Haipeng Yu
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes