Results 1 to 5 of 5

Thread: Crash in Qml destkop application.

  1. #1
    Join Date
    Jan 2008
    Posts
    20
    Thanks
    1

    Default Crash in Qml destkop application.

    Hi,

    I'm working on a medium sized desktop application, where the UI is made with QML. At the leftside of the application, we have a toolbar with 4 buttons which determine in which layout you are working. Each layout has a different set of toolbars and a docking view(with docked windows inside and a 3d render window). When switching between the layouts, the toolbars change, the docking view changes (with different number of docked windows with different content) and the render window changes. Just to say that a lot changes when you switch between layouts. Once in a while, when switching between layouts, the application just crashes. I found a repeatable sequence of actions to make it crash, but I'm completely lost where to go from here. At the moment I change the layout, i set a context property to a new pointer which triggers all the updates and at one point somewhere deep in qt5qml.dll an assert is triggered. The complete call stack (from VS2013) looks as follows:

    Qt Code:
    1. Qt5Cored.dll!qt_message_fatal(QtMsgType __formal, const QMessageLogContext & context, const QString & message) Line 1673 C++
    2. Qt5Cored.dll!QMessageLogger::fatal(const char * msg, ...) Line 793 C++
    3. Qt5Cored.dll!qt_assert(const char * assertion, const char * file, int line) Line 3064 C++
    4. Qt5Qmld.dll!QQmlAbstractBinding::~QQmlAbstractBinding() Line 56 C++
    5. Qt5Qmld.dll!QQmlBinding::~QQmlBinding() Line 144 C++
    6. [External Code]
    7. Qt5Cored.dll!QMetaObject::cast(const QObject * obj) Line 366 C++
    8. Qt5Cored.dll!QMetaObject::cast(QObject * obj) Line 356 C++
    9. Qt5Qmld.dll!qobject_cast<QObject * __ptr64>(QObject * object) Line 517 C++
    10. Qt5Qmld.dll!QtPrivate::QVariantValueHelper<QObject * __ptr64>::object(const QVariant & v) Line 710 C++
    11. Qt5Qmld.dll!QtPrivate::ObjectInvoker<QtPrivate::QVariantValueHelper<QObject * __ptr64>,QVariant const & __ptr64,QObject * __ptr64>::invoke(const QVariant & a) Line 103 C++
    12. Qt5Qmld.dll!qvariant_cast<QObject * __ptr64>(const QVariant & v) Line 836 C++
    13. Qt5Qmld.dll!VDMObjectDelegateDataType::createItem(QQmlAdaptorModel & model, QQmlDelegateModelItemMetaType * metaType, QQmlEngine * __formal, int index) Line 761 C++
    14. Qt5Qmld.dll!QQmlAdaptorModel::createItem(QQmlDelegateModelItemMetaType * metaType, QQmlEngine * engine, int index) Line 126 C++
    15. Qt5Qmld.dll!QQmlDelegateModelPrivate::object(QQmlListCompositor::Group group, int index, bool asynchronous) Line 936 C++
    16. Qt5Qmld.dll!QQmlDelegateModel::object(int index, bool asynchronous) Line 1023 C++
    17. Qt5Quickd.dll!QQuickRepeaterPrivate::requestItems() Line 400 C++
    18. Qt5Quickd.dll!QQuickRepeater::regenerate() Line 395 C++
    19. Qt5Quickd.dll!QQuickRepeater::componentComplete() Line 348 C++
    20. Qt5Qmld.dll!QQmlObjectCreator::finalize(QQmlInstantiationInterrupt & interrupt) Line 1218 C++
    21. Qt5Qmld.dll!QQmlIncubatorPrivate::incubate(QQmlInstantiationInterrupt & i) Line 354 C++
    22. Qt5Qmld.dll!QQmlEnginePrivate::incubate(QQmlIncubator & i, QQmlContextData * forContext) Line 95 C++
    23. Qt5Qmld.dll!QQmlComponent::create(QQmlIncubator & incubator, QQmlContext * context, QQmlContext * forContext) Line 1067 C++
    24. Qt5Quickd.dll!QQuickLoaderPrivate::_q_sourceLoaded() Line 723 C++
    25. Qt5Quickd.dll!QQuickLoaderPrivate::load() Line 604 C++
    26. Qt5Quickd.dll!QQuickLoader::componentComplete() Line 815 C++
    27. Qt5Qmld.dll!QQmlObjectCreator::finalize(QQmlInstantiationInterrupt & interrupt) Line 1218 C++
    28. Qt5Qmld.dll!QQmlIncubatorPrivate::incubate(QQmlInstantiationInterrupt & i) Line 354 C++
    29. Qt5Qmld.dll!QQmlEnginePrivate::incubate(QQmlIncubator & i, QQmlContextData * forContext) Line 95 C++
    30. ...
    To copy to clipboard, switch view to plain text mode 

    I know it's kinda long shot, but is there anybody who has an idea what could be the problem, or how I could find a starting point to look further. I already when through the call stack and checked some members to see if i could find a text or a class from my side, or a link to a qml file, but the only thing i see is internal qt code which I'm totally not familiar with.

    I narrowed the problem down a little bit. In each layout we have something called a viewmanager. It's basically a tabview with a tab for each type of item in the scene which are important for that layout. The model for the tabView is a

    Qt Code:
    1. Q_PROPERTY(QQmlListProperty<ViewManagerTabQMLInterface> tabsList READ getTabsList NOTIFY tabsListChanged);
    To copy to clipboard, switch view to plain text mode 


    the member QList is a

    Qt Code:
    1. QList<ViewManagerTabQMLInterface*> _tabsList;
    To copy to clipboard, switch view to plain text mode 

    the implementation for getting the tabs is like this:
    Qt Code:
    1. //--------------------------------------------------------------------------------------
    2. /// Returns the tablist
    3. //--------------------------------------------------------------------------------------
    4.  
    5. QQmlListProperty<ViewManagerTabQMLInterface> ViewManagerQMLInterface::getTabsList()
    6. {
    7. return QQmlListProperty<ViewManagerTabQMLInterface>(this, 0, &appendTab, &tabCount, &tabAt, &tabClear);
    8. }
    9.  
    10. //--------------------------------------------------------------------------------------
    11. /// Appends a tab
    12. //--------------------------------------------------------------------------------------
    13.  
    14. void ViewManagerQMLInterface::appendTab(QQmlListProperty<ViewManagerTabQMLInterface>* list, ViewManagerTabQMLInterface* p) {
    15. ViewManagerQMLInterface* vm = qobject_cast<ViewManagerQMLInterface*>(list->object);
    16. if (vm && p) {
    17. vm->_tabsList.append(p);
    18. emit vm->tabsListChanged();
    19. }
    20. }
    21.  
    22. //--------------------------------------------------------------------------------------
    23. /// Returns the number of tabs
    24. //--------------------------------------------------------------------------------------
    25.  
    26. int ViewManagerQMLInterface::tabCount(QQmlListProperty<ViewManagerTabQMLInterface>*list)
    27. {
    28. ViewManagerQMLInterface* vm = qobject_cast<ViewManagerQMLInterface*>(list->object);
    29. if (vm)
    30. return vm->_tabsList.count();
    31. return 0;
    32. }
    33.  
    34. //--------------------------------------------------------------------------------------
    35. /// Returns the tab at the given index
    36. //--------------------------------------------------------------------------------------
    37.  
    38. ViewManagerTabQMLInterface* ViewManagerQMLInterface::tabAt(QQmlListProperty<ViewManagerTabQMLInterface>* list, int i)
    39. {
    40. ViewManagerQMLInterface* vm = qobject_cast<ViewManagerQMLInterface*>(list->object);
    41. if (vm)
    42. return vm->_tabsList.at(i);
    43. return 0;
    44. }
    45.  
    46. //--------------------------------------------------------------------------------------
    47. /// Clears all the tabse
    48. //--------------------------------------------------------------------------------------
    49.  
    50. void ViewManagerQMLInterface::tabClear(QQmlListProperty<ViewManagerTabQMLInterface> *list)
    51. {
    52. ViewManagerQMLInterface* vm = qobject_cast<ViewManagerQMLInterface*>(list->object);
    53. if (vm){
    54. vm->_tabsList.clear();
    55. emit vm->tabsListChanged();
    56. }
    57. }
    To copy to clipboard, switch view to plain text mode 

    It seems like it has something to do with this. I found that the QQmlAdaptorModel is the model for the tabview...
    It also seems that it tries to create the tabs from the tabmodel from the previous layout after the new layout became active....
    Anyone can help me further?
    Regards,

    Jan

  2. #2
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Crash in Qml destkop application.

    Are those viewmanager instances available through out the program or do they get creates/deleted on demand?

    Do you have any Q_INVOKABLE methods that return instances of QObject derived classes?

    Cheers,
    _

  3. #3
    Join Date
    Jan 2008
    Posts
    20
    Thanks
    1

    Default Re: Crash in Qml destkop application.

    Hi,

    they are available through the entire lifetime of the application (the tabs are stored per layout in a QList<std::shared_ptr>. I have one Q_INVOKABLE method that returns a pointer to the tab.

    Qt Code:
    1. Q_INVOKABLE ViewManagerTabQMLInterface* getTab(int index);
    2.  
    3. //--------------------------------------------------------------------------------------
    4. /// Returns the tab model from the given index.
    5. //--------------------------------------------------------------------------------------
    6.  
    7. ViewManagerTabQMLInterface* ViewManagerQMLInterface::getTab(int index)
    8. {
    9. if(index >= 0 && index < (int)_tabsList.size())
    10. {
    11. return _tabsList[index].get();
    12. }
    13. return NULL;
    14. }
    To copy to clipboard, switch view to plain text mode 

    I see that at one point the destructor of the ViewManagerTabQMLInterface is called after a QDeleteDefferedEvent (just reading from the call stack).

    Qt Code:
    1. MeshingMaster.exe!ViewManagerTabQMLInterface::~ViewManagerTabQMLInterface() Line 69 C++
    2. [External Code]
    3. Qt5Cored.dll!qDeleteInEventHandler(QObject * o) Line 4482 C++
    4. > Qt5Cored.dll!QObject::event(QEvent * e) Line 1255 C++
    5. Qt5Widgetsd.dll!QApplicationPrivate::notify_helper(QObject * receiver, QEvent * e) Line 3799 C++
    6. Qt5Widgetsd.dll!QApplication::notify(QObject * receiver, QEvent * e) Line 3159 C++
    7. Qt5Cored.dll!QCoreApplication::notifyInternal2(QObject * receiver, QEvent * event) Line 988 C++
    8. Qt5Cored.dll!QCoreApplication::sendEvent(QObject * receiver, QEvent * event) Line 231 C++
    9. Qt5Cored.dll!QCoreApplicationPrivate::sendPostedEvents(QObject * receiver, int event_type, QThreadData * data) Line 1649 C++
    10. Qt5Cored.dll!QEventDispatcherWin32::sendPostedEvents() Line 1295 C++
    11. qwindowsd.dll!QWindowsGuiEventDispatcher::sendPostedEvents() Line 82 C++
    12. Qt5Cored.dll!qt_internal_proc(HWND__ * hwnd, unsigned int message, unsigned __int64 wp, __int64 lp) Line 445 C++
    13. [External Code]
    14. Qt5Cored.dll!QEventDispatcherWin32::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 845 C++
    15. qwindowsd.dll!QWindowsGuiEventDispatcher::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 74 C++
    16. Qt5Cored.dll!QEventLoop::processEvents(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 135 C++
    17. Qt5Cored.dll!QEventLoop::exec(QFlags<enum QEventLoop::ProcessEventsFlag> flags) Line 210 C++
    18. Qt5Cored.dll!QCoreApplication::exec() Line 1261 C++
    To copy to clipboard, switch view to plain text mode 

    Any idea?
    Last edited by anda_skoa; 16th December 2016 at 10:11. Reason: fix code end tags

  4. #4
    Join Date
    Jan 2006
    Location
    Graz, Austria
    Posts
    8,416
    Thanks
    37
    Thanked 1,544 Times in 1,494 Posts
    Qt products
    Qt3 Qt4 Qt5
    Platforms
    Unix/X11 Windows

    Default Re: Crash in Qml destkop application.

    Quote Originally Posted by JanW View Post
    they are available through the entire lifetime of the application (the tabs are stored per layout in a QList<std::shared_ptr>. I have one Q_INVOKABLE method that returns a pointer to the tab.
    Do those objects have a QObject parent?
    Or, alternatively, have they been marked as owned by C++ using QQmlEngine::setObjectOwnership()?

    Cheers,
    _

  5. #5
    Join Date
    Jan 2008
    Posts
    20
    Thanks
    1

    Default Re: Crash in Qml destkop application.

    Yes, they have a qobject parent, and yes, at one point they get deleted. I removed the passing of those objects via qml to my other class and now they stay alive.
    Thanks you very much for the tips!!!!
    Regards,

    Jan

Similar Threads

  1. Crash of the Server Application
    By 8Observer8 in forum Newbie
    Replies: 5
    Last Post: 3rd September 2013, 09:36
  2. how to avoid crash of my application......
    By newb in forum Qt Programming
    Replies: 1
    Last Post: 30th August 2010, 10:09
  3. application crash problem
    By anshul in forum Newbie
    Replies: 3
    Last Post: 25th December 2009, 12:27
  4. Application crash in Vista
    By yj... in forum Installation and Deployment
    Replies: 1
    Last Post: 5th June 2009, 08:18
  5. Weird application crash
    By MarkoSan in forum Qt Programming
    Replies: 10
    Last Post: 20th May 2008, 14:13

Bookmarks

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.