qquickvew删除导致应用程序崩溃
QQuickvew delete causing application to crash
破坏QquickView对象时QT 5.4发生崩溃。如果未设置setQuitOnLastWindowClosed
,默认true
,QDOC。
#include <QGuiApplication>
#include <QQuickView>
#include <QObject>
#include <QDebug>
class VDestroyer : public QObject
{
Q_OBJECT
public:
explicit VDestroyer(QQuickView *view, QObject *parent = 0) :
QObject(parent), m_view(view)
{
// destroy m_view in 5 secs
timerId = startTimer(5 * 1000);
}
protected:
void timerEvent(QTimerEvent * event)
{
if (event->timerId() == timerId) {
m_view->deleteLater();
}
}
private :
QQuickView *m_view;
int timerId;
};
int main(int argc, char *argv[])
{
QGuiApplication app(argc, argv);
app.setQuitOnLastWindowClosed(false);
QQuickView *view = new QQuickView;
view->setSource(QUrl(QStringLiteral("qrc:/main.qml")));
view->show();
VDestroyer *vDestroyer = new VDestroyer(view);
int rc = app.exec();
qDebug() << "exiting from application!!";
delete vDestroyer;
return rc;
}
#include "main.moc"
在此处可用的完整崩溃报告。
(gdb) bt
#0 0x00007f204bc47cf4 in QBasicAtomicOps<8>::testAndSetRelaxed<QMutexData*> (
_q_value=@0x48: <error reading variable>, expectedValue=0x0, newValue=0x1,
currentValue=0x7ffe453fa360)
at ../../include/QtCore/../../src/corelib/arch/qatomic_x86.h:259
#1 0x00007f204bc47af0 in QGenericAtomicOps<QBasicAtomicOps<8> >::testAndSetAcquire<QMutexData*, QMutexData*> (currentValue=0x7ffe453fa360, newValue=0x1, expectedValue=0x0,
_q_value=@0x48: <error reading variable>)
at ../../include/QtCore/../../src/corelib/thread/qgenericatomic.h:166
#2 QBasicAtomicPointer<QMutexData>::testAndSetAcquire (this=0x48, expectedValue=0x0,
newValue=0x1, currentValue=@0x7ffe453fa360: 0x7ffe453fa390)
at ../../include/QtCore/../../src/corelib/thread/qbasicatomic.h:270
#3 0x00007f204bc477ab in QBasicMutex::fastTryLock (this=0x48,
current=@0x7ffe453fa360: 0x7ffe453fa390) at thread/qmutex.h:82
#4 0x00007f204bc46fa4 in QMutex::lock (this=0x48) at thread/qmutex.cpp:212
#5 0x00007f204be8efd9 in QCoreApplication::postEvent (receiver=0x12fd0e0, event=0x1547610,
priority=0) at kernel/qcoreapplication.cpp:1305
#6 0x00007f204bed0fe2 in QObject::deleteLater (this=0x12fd0e0) at kernel/qobject.cpp:2125
#7 0x0000000000401c24 in qCleanupResources_qml () at qrc_qml.cpp:81
#8 0x00007f204becf1c7 in QObject::event (this=0x1518740, e=0x7ffe453fa760)
at kernel/qobject.cpp:1226
#9 0x00007f204be8ea82 in QCoreApplicationPrivate::notify_helper (this=0x12bfec0,
receiver=0x1518740, event=0x7ffe453fa760) at kernel/qcoreapplication.cpp:1052
#10 0x00007f204be8e709 in QCoreApplication::notify (this=0x7ffe453fab00, receiver=0x1518740,
event=0x7ffe453fa760) at kernel/qcoreapplication.cpp:997
#11 0x00007f204c27bb52 in QGuiApplication::notify (this=0x7ffe453fab00, object=0x1518740,
event=0x7ffe453fa760) at kernel/qguiapplication.cpp:1528
项目https://github.com/shrkamat/qlmresourcecleanup.git
应该允许运行使用应用程序事件循环销毁QquickView,对我来说就像QT错误。
qtimer默认情况下是重复的,http://doc.qt.io/qt-5/qtimer.html#singleshot-prop这将导致已删除已经被销毁的对象。
相关文章:
- 应用程序崩溃并显示"symbol _ZdlPvm, version Qt_5 not defined in file libQt5Core.so.5 with link time reference"
- 如何找出应用程序崩溃的原因 - Win 10 LTSB
- 操纵安卓相机的深度图导致应用程序崩溃
- 调用 java 的回调() 时应用程序崩溃.由于 detatchThread 而获得运行时错误
- QCompleter set模型使应用程序崩溃
- Qt 5 应用程序崩溃并出现"qLineEdit::setText"
- 切换NvAPI_Stereo_Deactivate/NvAPI_Stereo_activate会使unity应用程序崩溃
- eglSwapBuffers上的应用程序崩溃
- VLD 使应用程序崩溃
- 由于调用 std::condition_variable 后参数无效而导致应用程序崩溃
- 执行递归函数时 C++ 应用程序崩溃
- 在 C++/CLI/C# 项目中启用"Native Code Debugging"导致应用程序崩溃
- LOCAL_SHARED_LIBRARIES使我的应用程序崩溃
- 为什么使用 nullPtr 调用函数不会使我的应用程序崩溃
- 当删除上下文属性中的QLIST对象时,QT QML应用程序崩溃
- React 本机 0.59 应用程序崩溃并出现 libc 错误
- 当使用“制造”编译的程序中使用库时,应用程序崩溃
- 如何在导致应用程序崩溃的代码中修复指令
- C++多线程应用程序崩溃
- 当使用 /ENTRY:main 和 /MT 运行时库编译为 /SUBSYSTEM:WINDOWS 时,应用程序崩溃