1,下面的代码导致了内存泄漏
auto item=QSharedPointer ( new MyClass(),&QObject::deleteLater)
2,去掉了自定义析构后,内存泄漏问题解除,但是导致了新的问题,
auto item=QSharedPointer<MyClass> ( new MyClass())
在item析构时出现了析构错误:
QCoreApplication::sendEvent: “cannot send events to objects owned by a different thread
将代码改成
auto item=QSharedPointer<MyClass> ( new MyClass(),&MyClass::deleteLater)
后,析构错误消除
标签:QSharedPointer,item,内存,析构,new,MyClass From: https://www.cnblogs.com/fastexpress/p/17421601.html