Results 1 to 1 of 1

Thread: Crash in QQmlValueWrappert::typeId()

  1. #1
    Join Date
    Jan 2008

    Default Crash in QQmlValueWrappert::typeId()


    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*>("ModelEditorTr ee*"); ...) 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::readRefer enceValue() 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, endRemoveRows and emit datachanged are called during the removal of the item.
    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?

    Last edited by JanW; 15th September 2017 at 16:21.

Similar Threads

  1. Replies: 0
    Last Post: 3rd November 2015, 17:58
  2. qml crash
    By waiter in forum Qt Quick
    Replies: 0
    Last Post: 11th July 2013, 02:43
  3. Crash on connect
    By trust88 in forum Qt Programming
    Replies: 2
    Last Post: 3rd May 2013, 17:44
  4. Crash gracefully? No crash!
    By lni in forum Qt Programming
    Replies: 0
    Last Post: 7th July 2010, 03:59
  5. qobject_cast() and typeid() problem
    By codeslicer in forum Qt Programming
    Replies: 4
    Last Post: 24th January 2009, 00:07


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
Digia, Qt and their respective logos are trademarks of Digia Plc in Finland and/or other countries worldwide.