QGraphicsScene::~QGraphicsScene() 分段错误
再会!
对于 Qt 4.7.3,下面的示例在 QGraphicsScene::~QGraphicsScene() 调用中崩溃:
#include <QCoreApplication>
#include <QGraphicsScene>
int main( int argc, char* argv[] )
{
// replace this with QObject app; and no problems
QCoreApplication app( argc, argv );
new QGraphicsScene( &app );
return 0;
}
有什么想法吗?
更新:
已创建错误报告。
Good day!
With Qt 4.7.3 an example below crashes at QGraphicsScene::~QGraphicsScene() call:
#include <QCoreApplication>
#include <QGraphicsScene>
int main( int argc, char* argv[] )
{
// replace this with QObject app; and no problems
QCoreApplication app( argc, argv );
new QGraphicsScene( &app );
return 0;
}
Any ideas?
UPDATE:
Bug report created.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
当构建
QGraphicsScene
实例时,它将自身附加到存储在单个QApplication
实例的私有成员中的列表中,当删除它时,它也会从该列表中删除自己:当应用程序对象被销毁时,继承的基类的析构函数会被递归调用,因此,
~QApplication()
调用~QCoreApplication()
,而~QCoreApplication()
本身又调用~QObject()
。子对象的实际删除是在
~QObject()
中完成的。这意味着在场景对象被销毁时,所有
QApplication
成员都已被销毁,因此~QGraphicsScene()
在尝试访问列表时崩溃。When a
QGraphicsScene
instance is constructed it appends itself in a list stored in a private member of the singleQApplication
instance, and when it is deleted, it also remove itself from that list:When the application object is destroyed, the inherited base class' destructors are called recursively, so,
~QApplication()
calls~QCoreApplication()
which itself calls~QObject()
.The actual deletion of child objects is done in
~QObject()
.Which means that at the time the scene object is destroyed, all the
QApplication
members are already destroyed, so~QGraphicsScene()
crashes when it tries to access the list.