Uploaded image for project: 'Qt'
  1. Qt
  2. QTBUG-50169

OSX AbstractListModel Model Destructor Called

    XMLWordPrintable

Details

    • Bug
    • Resolution: Invalid
    • Not Evaluated
    • None
    • 5.5.1
    • QPA
    • None
    • OSX El Capitan Qt 5.5.1 XCode 6.3.2
    • macOS

    Description

      I have not reproduced this on any other platform, only OSX.

      But the usage of AbstractListModel and beginResetModel()/endResetModel() is not stable on OSX.

      Qt is calling the overridden AbstractListModel destructor.

      I my case, my class override name is Trpzmodel, so when I look at the exception stack trace, I see the stack show a route through a model destructor, but NOWHERE in my code is there such a call, explicit or implicit to destructor.

      thread #1: tid = 0xd5f5, 0x00007fff822b80ae libsystem_kernel.dylib`__pthread_kill + 10, queue = 'com.apple.main-thread', stop reason = signal SIGABRT

      • frame #0: 0x00007fff822b80ae libsystem_kernel.dylib`__pthread_kill + 10
        frame #1: 0x00007fff89d8a500 libsystem_pthread.dylib`pthread_kill + 90
        frame #2: 0x00007fff8c7d937b libsystem_c.dylib`abort + 129
        frame #3: 0x00007fff87ca3051 libsystem_malloc.dylib`free + 425
        frame #4: 0x000000010001aca2 testalert`Trpzmodel::~Trpzmodel(this=0x00007fff5fbff568) + 34 at rpzmodel.cpp:144
        frame #5: 0x0000000100c77ef8 QtCore`QObject::event(QEvent*) + 856
        frame #6: 0x0000000100c4ea6a QtCore`QCoreApplication::notify(QObject*, QEvent*) + 170
        frame #7: 0x0000000100c4f65b QtCore`QCoreApplicationPrivate::sendPostedEvents(QObject*, int, QThreadData*) + 971
        frame #8: 0x000000010256f91e libqcocoa.dylib`QCocoaEventDispatcherPrivate::processPostedEvents() + 190
        frame #9: 0x00000001025701a1 libqcocoa.dylib`QCocoaEventDispatcherPrivate::postedEventsSourceCallback(void*) + 33
        frame #10: 0x00007fff89fc5621 CoreFoundation`_CFRUNLOOP_IS_CALLING_OUT_TO_A_SOURCE0_PERFORM_FUNCTION_ + 17
        frame #11: 0x00007fff89fa4e1c CoreFoundation`__CFRunLoopDoSources0 + 556
        frame #12: 0x00007fff89fa433f CoreFoundation`__CFRunLoopRun + 927
        frame #13: 0x00007fff89fa3d38 CoreFoundation`CFRunLoopRunSpecific + 296
        frame #14: 0x00007fff854fed55 HIToolbox`RunCurrentEventLoopInMode + 235
        frame #15: 0x00007fff854feb8f HIToolbox`ReceiveNextEventCommon + 432
        frame #16: 0x00007fff854fe9cf HIToolbox`_BlockUntilNextEventMatchingListInModeWithFilter + 71
        frame #17: 0x00007fff92633f3a AppKit`_DPSNextEvent + 1067
        frame #18: 0x00007fff92633369 AppKit`-[NSApplication _nextEventMatchingEventMask:untilDate:inMode:dequeue:] + 454
        frame #19: 0x00007fff92627ecc AppKit`-[NSApplication run] + 682
        frame #20: 0x000000010256f08d libqcocoa.dylib`QCocoaEventDispatcher::processEvents(QFlags<QEventLoop::ProcessEventsFlag>) + 2189
        frame #21: 0x0000000100c4c07d QtCore`QEventLoop::exec(QFlags<QEventLoop::ProcessEventsFlag>) + 381
        frame #22: 0x0000000100c4ef5a QtCore`QCoreApplication::exec() + 346
        frame #23: 0x000000010000404a testalert`main(argc=1, argv=0x00007fff5fbffc28) + 778 at main.cpp:36
        frame #24: 0x0000000100003d34 testalert`start + 52

      Now, I load my model in QML using an INVOKABLE:

      Q_INVOKABLE Trpzmodel* gmodel(const QString& gsmodel) and it works fine in qml:

      Listview

      { id: glist model: Rpz.gmodel("TESTMODEL") delegate: etc.... }

      When I call, this->beginResetModel() and this->endResetModel() during list repaint operations, I trigger the following exception:

      testalert(1543,0x7fff72265000) malloc: *** error for object 0x7fff5fbff568: pointer being freed was not allocated

          • set a breakpoint in malloc_error_break to debug

      Since I only allocate the models at the beginning of the program ONCE and are never destroyed.

      When I comment out (this->beginResetModel()/this->endResetModel()), the program no longer throws exceptions but the list is NOT updated.

      There must be a way to cause the ListView to repaint in a safe way.

      Attachments

        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            sorvig Morten Sørvig
            qtmarco mark diener
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes