Crash in QQmlValueTypeWrapper::typeId()

  • Hi,

    I recently made the switch from Qt 5.7 to Qt 5.9 and since then I have some strange crash in code that was working before. The crash happens when I try to remove an item from a tree.

    To give you some background (hopefully with some relevant info): We have a hybrid C++/QML application which uses an entity/component/system structure. The trees only contain (string representations of) entities. Each tree is represented by a template. Such a template is a list of components which an entity should have so it is added to the tree at a certain location (subitem of other entity). A tree is a so called system: it is notified when entities change, are added, removed,... . When something like that happens, the tree checks the entity against its template to see if it needs to be added/removed/changed from position/renamed/... . This is all implemented in a parent interface class (ECTreeModel) which subclasses from QAbstractItemModel. Next to that, I have the real implementations of the trees (i have 3 trees at this moment). The subclasses basically just define how the template of that tree looks like.
    The ECTreeModel and the trees are all registered as meta type (qRegisterMetaType<ECTreeModel*>("ECTreeModel*"); qRegisterMetaType<ModelEditorTree*>("ModelEditorTree*"); ...) to be used as the model of a qml TreeView.

    At one point, when an item is removed from the tree, I get a crash in QQmlValueWrappert::typeId(), valueType was nullptr;

    full call stack:
    Qt5Qmld.dll!QV4::QQmlValueTypeWrapper::typeId() Line 287 C++ Symbols loaded.
    Qt5Qmld.dll!QV4::QQmlValueTypeReference::readReferenceValue() Line 134 C++ Symbols loaded.
    Qt5Qmld.dll!QV4::QQmlValueTypeWrapper::toVariant() Line 210 C++ Symbols loaded.
    Qt5Qmld.dll!toVariant(QV4::ExecutionEngine * e, const QV4::Value & value, int typeHint, bool createJSValueForObjects, QSet<QV4::Heap::Object *> * visitedObjects) Line 1127 C++ Symbols loaded.
    Qt5Qmld.dll!QV4::ExecutionEngine::toVariant(const QV4::Value & value, int typeHint, bool createJSValueForObjects) Line 1094 C++ Symbols loaded.
    Qt5Qmld.dll!`anonymous namespace'::CallArgument::fromValue(int callType, QV4::ExecutionEngine * engine, const QV4::Value & value) Line 1610 C++ Symbols loaded.
    Qt5Qmld.dll!CallMethod(const QQmlObjectOrGadget & object, int index, int returnType, int argCount, int * argTypes, QV4::ExecutionEngine * engine, QV4::CallData * callArgs, QMetaObject::Call callType) Line 1078 C++ Symbols loaded.
    Qt5Qmld.dll!CallPrecise(const QQmlObjectOrGadget & object, const QQmlPropertyData & data, QV4::ExecutionEngine * engine, QV4::CallData * callArgs, QMetaObject::Call callType) Line 1345 C++ Symbols loaded.
    Qt5Qmld.dll!QV4::QObjectMethod::callInternal(QV4::CallData * callData, QV4::Scope & scope) Line 1839 C++ Symbols loaded.
    Qt5Qmld.dll!QV4::QObjectMethod::call(const QV4::Managed * m, QV4::Scope & scope, QV4::CallData * callData) Line 1769 C++ Symbols loaded.
    Qt5Qmld.dll!QV4::Object::call(QV4::Scope & scope, QV4::CallData * d) Line 362 C++ Symbols loaded.
    Qt5Qmld.dll!QV4::Runtime::method_callProperty(QV4::ExecutionEngine * engine, int nameIndex, QV4::CallData * callData) Line 1049 C++ Symbols loaded.
    [External Code] Annotated Frame

    I checked the code and I don't see directly any problem in the QAbstractItemModel: all item pointers are valid and logical (pointing to the correct item, also with the correct entity representation). I also don't have persistent model indices (I look them up on the fly) and there is nothing happening in a separate thread.
    BeginremoveRows, endremoverow are called as well as emit dataChanged.
    At the end, i do call something like modelEditorTreeChanged signal and in a connected slot I do emit modelsTreeChanged(); which calls the getter of the modeleditortree (It is something historical, but it was working normal before). It get's into the getter and after that the crash occurs.

    I'm quite lost were to search for the error. My first thought was that something was wrong with some qmodelindices (had a lot of issues before because my lack of knowledge, but they all seemed to be fixed), but the call stack rather seems to tell something abt an issue with registered types (I'm just wildly guessing here, I'm totally not familiar with the qt quick internals :) )?
    Has anybody have any idea what could be a cause of the crash and why it was working in 5.7 and in 5.9 not anymore?


Log in to reply

Looks like your connection to Qt Forum was lost, please wait while we try to reconnect.