QSharedPointer reset()
Solved
General and Desktop
-
qDebug() << "START"; for (int i = 0; i < 5; i++) { if (list.length() >= 1) qDebug() << list.last().data()->objectName(); QSharedPointer<QObject> tmp = QSharedPointer<QObject>(new QObject()); tmp.data()->setObjectName("Test"); list.append(QSharedPointer<QObject>(new QObject())); list.last().reset(tmp.data()); } qDebug() << "END";
Please explain to me, why the objectName 'Test' is lost on the list entry. When tmp is destructed the name gets lost, even though I set the list entry to point to the same QObject
Btw, when qDebug() is called, the program crashes
-
-
-
-
-