Important: Please read the Qt Code of Conduct -

Component.onDestruction() causing segfault on closing applicaton

  • Hey guys, in one of my QML files I am calling a Q_INVOKABLE function whenever Component.onDestruction() occurs. This action in it of itself does not cause a seg fault. However, if I close the application while in the menu that this QML file is controlling I get a segfault here on line 163 of qjsengine_p.h:

    Returns a QQmlPropertyCache for \a obj if one is available.
    If \a obj is null, being deleted or contains a dynamic meta object 0
    is returned.
    The returned cache is not referenced, so if it is to be stored, call addref().
    XXX thread There is a potential future race condition in this and all the cache()
    functions.  As the QQmlPropertyCache is returned unreferenced, when called
    from the loader thread, it is possible that the cache will have been dereferenced
    and deleted before the loader thread has a chance to use or reference it.  This
    can't currently happen as the cache holds a reference to the
    QQmlPropertyCache until the QQmlEngine is destroyed.
    QQmlPropertyCache *QJSEnginePrivate::cache(QObject *obj)
        if (!obj || QObjectPrivate::get(obj)->metaObject || QObjectPrivate::get(obj)->wasDeleted)
            return nullptr;
        Locker locker(this);
        const QMetaObject *mo = obj->metaObject();
        return QQmlMetaType::propertyCache(mo);

    if I remove the Componenet.onDestruction() code then there is no seg fault on closing the application in that menu. Here is how I am using Component.onDestruction() in the code itself:

    id: advancedSettings
            title: qsTr("Advanced Settings")
            canOpen: true
            Component.onDestruction: presenter.configureReceiver()

    am I using this incorrectly?

Log in to reply