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

"ScrollView + ListView + DelegateModel" crashes when `reuseItems: true` and the size of ScrollView depends on delegate items

    XMLWordPrintable

Details

    • Bug
    • Resolution: Fixed
    • P1: Critical
    • None
    • 5.15.2
    • None
    • Linux/X11
    • 0cfdecba54e4f40468c4c9a8a6668cc1bc0eff65

    Description

      When the size (height) of ScrollView depends on its delegate items and `reuseItems` is set to true, the program is prone to crash.

      I have created a simple program based on `QFileSystemModel` to reproduce the bug. The video in the attachment shows how to reproduce the bug.

      See also: https://bugs.kde.org/show_bug.cgi?id=452660

      Backtrace

       

      (gdb) bt 
      #0  QQmlDelegateModelItem::destroyObject (this=0xc3afd0) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-ku.2.1.x86_64/src/qmlmodels/qqmldelegatemodel.cpp:2422 
      #1  0x00007ffff72c66e3 in QQmlDelegateModelPrivate::destroyCacheItem (cacheItem=0xc3afd0, this=0x5a0570) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-ku.2.1.x8
      6_64/src/qmlmodels/qqmldelegatemodel.cpp:644                                                                                                                           
      #2  operator() (cacheItem=0xc3afd0, __closure=<optimized out>) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-ku.2.1.x86_64/src/qmlmodels/qqmldelegatemodel.cpp:1
      118 
      #3  std::__invoke_impl<void, QQmlDelegateModelPrivate::drainReusableItemsPool(int)::<lambda(QQmlDelegateModelItem*)>&, QQmlDelegateModelItem*> (__f=...) at /usr/inclu
      de/c++/11/bits/invoke.h:61                                                                                                                                             
      #4  std::__invoke_r<void, QQmlDelegateModelPrivate::drainReusableItemsPool(int)::<lambda(QQmlDelegateModelItem*)>&, QQmlDelegateModelItem*> (__fn=...) at /usr/include
      /c++/11/bits/invoke.h:111                                                                                                                                              
      #5  std::_Function_handler<void(QQmlDelegateModelItem*), QQmlDelegateModelPrivate::drainReusableItemsPool(int)::<lambda(QQmlDelegateModelItem*)> >::_M_invoke(const st
      d::_Any_data &, QQmlDelegateModelItem *&&) (__functor=..., __args#0=<optimized out>) at /usr/include/c++/11/bits/std_function.h:290                                    
      #6  0x00007ffff72c5991 in std::function<void (QQmlDelegateModelItem*)>::operator()(QQmlDelegateModelItem*) const (__args#0=0xc3afd0, this=0x7fffffff7680) at /usr/incl
      ude/c++/11/bits/std_function.h:590                                                                                                                                     
      #7  QQmlReusableDelegateModelItemsPool::drain(int, std::function<void (QQmlDelegateModelItem*)>) (this=0x5a0768, maxPoolTime=0, releaseItem=...) at /usr/src/debug/lib
      qt5-qtdeclarative-5.15.2+kde43-ku.2.1.x86_64/src/qmlmodels/qqmldelegatemodel.cpp:3821                                                                                  
      #8  0x00007ffff72c5ce0 in QQmlDelegateModelPrivate::drainReusableItemsPool (maxPoolTime=<optimized out>, this=<optimized out>) at /usr/src/debug/libqt5-qtdeclarative-
      5.15.2+kde43-ku.2.1.x86_64/src/qmlmodels/qqmldelegatemodel.cpp:1118                                                                                                    
      #9  QQmlDelegateModel::drainReusableItemsPool (this=<optimized out>, maxPoolTime=<optimized out>) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-ku.2.1.x86_64/sr
      c/qmlmodels/qqmldelegatemodel.cpp:1123                                                                                                                                 
      #10 0x00007ffff7d56244 in QQuickListView::geometryChanged (this=0x79b870, newGeometry=..., oldGeometry=...) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-ku.2.1
      .x86_64/src/quick/items/qquicklistview.cpp:3418                                                                                                                        
      #11 0x00007ffff7c73d3b in QQuickItem::setSize (this=this@entry=0x79b870, size=...) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-ku.2.1.x86_64/src/quick/items/q
      quickitem.cpp:7037                                                                                                                                                     
      #12 0x00007ffff0a20c75 in QQuickControlPrivate::resizeContent (this=<optimized out>) at /usr/src/debug/libqt5-qtquickcontrols2-5.15.2+kde10-ku.1.1.x86_64/src/quicktem
      plates2/qquickcontrol.cpp:402                                                                                                                                          
      #13 0x00007ffff0a23442 in QQuickControl::paddingChange (this=<optimized out>, newPadding=..., oldPadding=...) at /usr/src/debug/libqt5-qtquickcontrols2-5.15.2+kde10-k
      u.1.1.x86_64/src/quicktemplates2/qquickcontrol.cpp:2261                                                                                                                
      #14 0x00007ffff0a1cd3d in QQuickControlPrivate::setRightPadding (this=0x7502e0, value=<optimized out>, reset=<optimized out>) at /usr/src/debug/libqt5-qtquickcontrols
      2-5.15.2+kde10-ku.1.1.x86_64/src/quicktemplates2/qquickcontrol.cpp:272                                                                                                 
      #15 0x00007ffff70d706f in QQmlPropertyData::writeProperty (flags=..., value=0x7fffffff7898, target=<optimized out>, this=<optimized out>) at ../../include/QtQml/5.15.
      2/QtQml/private/../../../../../../src/qml/qml/qqmlpropertydata_p.h:375                                                                                                 
      #16 GenericBinding<6>::doStore<double> (flags=..., pd=<optimized out>, value=<optimized out>, this=0x75b420) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-ku.2.
      1.x86_64/src/qml/qml/qqmlbinding.cpp:342                                                                                                                               
      #17 GenericBinding<6>::write (this=0x75b420, result=..., isUndefined=<optimized out>, flags=...) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-ku.2.1.x86_64/src
      /qml/qml/qqmlbinding.cpp:315                                                                                                                                           
      #18 0x00007ffff70d7ea7 in QQmlNonbindingBinding::doUpdate (this=0x75b420, watcher=..., flags=..., scope=...) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-ku.2.
      1.x86_64/src/qml/qml/qqmlbinding.cpp:258                                                                                                                               
      #19 0x00007ffff70d5ac4 in QQmlBinding::update (this=0x75b420, flags=...) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-ku.2.1.x86_64/src/qml/qml/qqmlbinding.cpp
      :194 
      #20 0x00007ffff70b2c95 in QQmlNotifier::emitNotify (endpoint=<optimized out>, a=0x0) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-ku.2.1.x86_64/src/qml/qml/qqm
      lnotifier.cpp:104                                                                                                                                                      
      #21 0x00007ffff624afb8 in doActivate<false> (sender=0x758400, signal_index=4, argv=argv@entry=0x0) at kernel/qobject.cpp:3778 
      #22 0x00007ffff62449cd in QMetaObject::activate (sender=<optimized out>, signalOffset=<optimized out>, local_signal_index=<optimized out>, argv=argv@entry=0x0) at ker
      nel/qobject.cpp:3959                                                                                                                                                   
      #23 0x00007ffff7059535 in QQmlVMEMetaObject::activate (this=this@entry=0x7612d0, object=<optimized out>, index=<optimized out>, args=args@entry=0x0) at /usr/src/debug
      /libqt5-qtdeclarative-5.15.2+kde43-ku.2.1.x86_64/src/qml/qml/qqmlvmemetaobject.cpp:1312                                                                                
      #24 0x00007ffff705bc3f in QQmlVMEMetaObject::metaCall (this=0x7612d0, o=<optimized out>, c=<optimized out>, _id=<optimized out>, a=<optimized out>) at /usr/src/debug/
      libqt5-qtdeclarative-5.15.2+kde43-ku.2.1.x86_64/src/qml/qml/qqmlvmemetaobject.cpp:880                                                                                  
      #25 0x00007ffff70d7040 in QQmlPropertyData::writeProperty (flags=..., value=0x7fffffff94c8, target=<optimized out>, this=<optimized out>) at ../../include/QtQml/5.15.
      2/QtQml/private/../../../../../../src/qml/qml/qqmlpropertydata_p.h:379                                                                                                 
      #26 GenericBinding<6>::doStore<double> (flags=..., pd=<optimized out>, value=<optimized out>, this=0x7e77b0) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-ku.2.
      1.x86_64/src/qml/qml/qqmlbinding.cpp:342                                                                                                                               
      #27 GenericBinding<6>::write (this=0x7e77b0, result=..., isUndefined=<optimized out>, flags=...) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-ku.2.1.x86_64/src
      /qml/qml/qqmlbinding.cpp:315                                                                                                                                           
      #28 0x00007ffff70d7ea7 in QQmlNonbindingBinding::doUpdate (this=0x7e77b0, watcher=..., flags=..., scope=...) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-ku.2.
      1.x86_64/src/qml/qml/qqmlbinding.cpp:258                                                                                                                               
      #29 0x00007ffff70d5ac4 in QQmlBinding::update (this=0x7e77b0, flags=...) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-ku.2.1.x86_64/src/qml/qml/qqmlbinding.cpp
      :194 
      #30 0x00007ffff70b2c95 in QQmlNotifier::emitNotify (endpoint=<optimized out>, a=0x0) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-ku.2.1.x86_64/src/qml/qml/qqm
      lnotifier.cpp:104                                                                                                                                                      
      #31 0x00007ffff624afb8 in doActivate<false> (sender=0x792300, signal_index=18, argv=0x0) at kernel/qobject.cpp:3778 
      #32 0x00007ffff62447af in QMetaObject::activate (sender=sender@entry=0x792300, m=m@entry=0x7ffff7f68e20 <QQuickItem::staticMetaObject>, local_signal_index=local_signa
      l_index@entry=15, argv=argv@entry=0x0) at kernel/qobject.cpp:3946                                                                                                      
      #33 0x00007ffff7c64d33 in QQuickItem::visibleChanged (this=this@entry=0x792300) at .moc/moc_qquickitem.cpp:1170 
      #34 0x00007ffff7c750c7 in QQuickItemPrivate::setEffectiveVisibleRecur (this=this@entry=0x7923c0, newEffectiveVisible=<optimized out>) at /usr/src/debug/libqt5-qtdecla
      rative-5.15.2+kde43-ku.2.1.x86_64/src/quick/items/qquickitem.cpp:6081                                                                                                  
      #35 0x00007ffff7c75153 in QQuickItemPrivate::setVisible (this=0x7923c0, visible=<optimized out>) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-ku.2.1.x86_64/src
      /quick/items/qquickitem.cpp:5975                                                                                                                                       
      #36 0x00007ffff70d749f in QQmlPropertyData::writeProperty (flags=..., value=0x7fffffffb06f, target=<optimized out>, this=<optimized out>) at ../../include/QtQml/5.15.
      2/QtQml/private/../../../../../../src/qml/qml/qqmlpropertydata_p.h:375                                                                                                 
      #37 GenericBinding<1>::doStore<bool> (flags=..., pd=<optimized out>, value=<optimized out>, this=<optimized out>) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-
      ku.2.1.x86_64/src/qml/qml/qqmlbinding.cpp:342                                                                                                                          
      #38 GenericBinding<1>::write (this=0x7993d0, result=..., isUndefined=<optimized out>, flags=...) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-ku.2.1.x86_64/src
      /qml/qml/qqmlbinding.cpp:305                                                                                                                                           
      #39 0x00007ffff70d7ea7 in QQmlNonbindingBinding::doUpdate (this=0x7993d0, watcher=..., flags=..., scope=...) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-ku.2.
      1.x86_64/src/qml/qml/qqmlbinding.cpp:258                                                                                                                               
      #40 0x00007ffff70d5ac4 in QQmlBinding::update (this=0x7993d0, flags=...) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-ku.2.1.x86_64/src/qml/qml/qqmlbinding.cpp
      :194 
      #41 0x00007ffff70b2c95 in QQmlNotifier::emitNotify (endpoint=<optimized out>, a=0x0) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-ku.2.1.x86_64/src/qml/qml/qqm
      lnotifier.cpp:104                                                                                                                                                      
      #42 0x00007ffff624afb8 in doActivate<false> (sender=0x792300, signal_index=61, argv=0x0) at kernel/qobject.cpp:3778 
      #43 0x00007ffff0a53f5b in QQuickScrollBar::setSize (this=0x792300, size=<optimized out>) at /usr/src/debug/libqt5-qtquickcontrols2-5.15.2+kde10-ku.1.1.x86_64/src/quic
      ktemplates2/qquickscrollbar.cpp:353                                                                                                                                    
      #44 0x00007ffff624b488 in doActivate<false> (sender=0x75f7f0, signal_index=6, argv=0x7fffffffcce0) at kernel/qobject.cpp:3898 
      #45 0x00007ffff62447af in QMetaObject::activate (sender=<optimized out>, m=m@entry=0x7ffff7f7f8e0 <QQuickFlickableVisibleArea::staticMetaObject>, local_signal_index=l
      ocal_signal_index@entry=3, argv=argv@entry=0x7fffffffcce0) at kernel/qobject.cpp:3946                                                                                  
      #46 0x00007ffff7e33cc3 in QQuickFlickableVisibleArea::heightRatioChanged (this=<optimized out>, _t1=<optimized out>) at .moc/moc_qquickflickable_p_p.cpp:242 
      #47 0x00007ffff7d41e6e in QQuickItemViewPrivate::regenerate (this=0x79b930, orientationChanged=<optimized out>) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-ku
      .2.1.x86_64/src/quick/items/qquickitemview.cpp:1846                                                                                                                    
      #48 0x00007ffff7d4310a in QQuickItemViewPrivate::regenerate (orientationChanged=false, this=0x79b930) at ../../include/QtQmlModels/5.15.2/QtQmlModels/private/../../..
      /../../../src/qmlmodels/qqmlchangeset_p.h:127                                                                                                                          
      #49 QQuickItemView::modelUpdated (this=0x79b870, changeSet=..., reset=<optimized out>) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-ku.2.1.x86_64/src/quick/ite
      ms/qquickitemview.cpp:1247                                                                                                                                             
      #50 0x00007ffff624b488 in doActivate<false> (sender=0x79d660, signal_index=4, argv=0x7fffffffce50) at kernel/qobject.cpp:3898 
      #51 0x00007ffff62447af in QMetaObject::activate (sender=<optimized out>, m=m@entry=0x7ffff72fad60 <QQmlInstanceModel::staticMetaObject>, local_signal_index=local_sign
      al_index@entry=1, argv=argv@entry=0x7fffffffce50) at kernel/qobject.cpp:3946                                                                                           
      #52 0x00007ffff729b016 in QQmlInstanceModel::modelUpdated (this=<optimized out>, _t1=..., _t2=<optimized out>) at .moc/moc_qqmlobjectmodel_p.cpp:263 
      #53 0x00007ffff72bb2c8 in non-virtual thunk to QQmlDelegateModelPrivate::emitModelUpdated(QQmlChangeSet const&, bool) () at /usr/src/debug/libqt5-qtdeclarative-5.15.2
      +kde43-ku.2.1.x86_64/src/qmlmodels/qqmldelegatemodel.cpp:2495                                                                                                          
      #54 0x00007ffff72c172a in QQmlDelegateModelGroupPrivate::emitModelUpdated (this=0x79d720, reset=reset@entry=true) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-
      ku.2.1.x86_64/src/qmlmodels/qqmldelegatemodel.cpp:2745                                                                                                                 
      #55 0x00007ffff72c1b30 in QQmlDelegateModelPrivate::emitChanges (this=this@entry=0x5a0570) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-ku.2.1.x86_64/src/qmlmo
      dels/qqmldelegatemodel.cpp:1868                                                                                                                                        
      #56 0x00007ffff72cd16d in QQmlDelegateModel::_q_modelReset (this=<optimized out>) at /usr/src/debug/libqt5-qtdeclarative-5.15.2+kde43-ku.2.1.x86_64/src/qmlmodels/qqml
      delegatemodel.cpp:1918                                                                                                                                                 
      #57 0x00007ffff72cdd9b in QQmlDelegateModel::qt_metacall (this=0x79d660, _c=QMetaObject::InvokeMetaMethod, _id=17, _a=0x7fffffffd0b0) at .moc/moc_qqmldelegatemodel_p.
      cpp:371                                                                                                                                                                
      #58 0x00007ffff624b1a5 in doActivate<false> (sender=0x7fffffffd5d0, signal_index=6, argv=0x7fffffffd0b0) at kernel/qobject.cpp:3912 
      #59 0x00007ffff62447af in QMetaObject::activate (sender=sender@entry=0x7fffffffd5d0, m=m@entry=0x7ffff64e8d60 <QAbstractItemModel::staticMetaObject>, local_signal_ind
      ex=local_signal_index@entry=3, argv=argv@entry=0x7fffffffd0b0) at kernel/qobject.cpp:3946                                                                              
      #60 0x00007ffff61af176 in QAbstractItemModel::layoutChanged (this=this@entry=0x7fffffffd5d0, _t1=..., _t2=<optimized out>, _t2@entry=QAbstractItemModel::NoLayoutChang
      eHint) at .moc/moc_qabstractitemmodel.cpp:571 
      #61 0x00007ffff76d5c9f in QFileSystemModel::sort (this=0x7fffffffd5d0, column=<optimized out>, order=<optimized out>) at dialogs/qfilesystemmodel.cpp:1183 
      #62 0x00007ffff624128e in QObject::event (this=0x7fffffffd5d0, e=0x7fff9c17a6d0) at kernel/qobject.cpp:1314 
      #63 0x00007ffff74a4b0f in QApplicationPrivate::notify_helper (this=<optimized out>, receiver=0x7fffffffd5d0, e=0x7fff9c17a6d0) at kernel/qapplication.cpp:3632 
      #64 0x00007ffff6214b5a in QCoreApplication::notifyInternal2 (receiver=0x7fffffffd5d0, event=0x7fff9c17a6d0) at kernel/qcoreapplication.cpp:1064 
      #65 0x00007ffff6217b97 in QCoreApplicationPrivate::sendPostedEvents (receiver=0x0, event_type=0, data=0x43ad80) at kernel/qcoreapplication.cpp:1821 
      #66 0x00007ffff626cc33 in postEventSourceDispatch (s=s@entry=0x5208e0) at kernel/qeventdispatcher_glib.cpp:277 
      #67 0x00007ffff4b9e122 in g_main_dispatch (context=0x7fffec005010) at ../glib/gmain.c:3417 
      #68 g_main_context_dispatch (context=0x7fffec005010) at ../glib/gmain.c:4135 
      #69 0x00007ffff4b9e4b8 in g_main_context_iterate (context=context@entry=0x7fffec005010, block=block@entry=1, dispatch=dispatch@entry=1, self=<optimized out>) at ../gl
      ib/gmain.c:4211                                                                                                                                                        
      #70 0x00007ffff4b9e56f in g_main_context_iteration (context=0x7fffec005010, may_block=1) at ../glib/gmain.c:4276 
      #71 0x00007ffff626c2b4 in QEventDispatcherGlib::processEvents (this=0x52e600, flags=...) at kernel/qeventdispatcher_glib.cpp:423 
      #72 0x00007ffff621355b in QEventLoop::exec (this=this@entry=0x7fffffffd540, flags=..., flags@entry=...) at ../../include/QtCore/../../src/corelib/global/qflags.h:69 
      #73 0x00007ffff621b820 in QCoreApplication::exec () at ../../include/QtCore/../../src/corelib/global/qflags.h:121 
      #74 0x00007ffff666561c in QGuiApplication::exec () at kernel/qguiapplication.cpp:1867 
      #75 0x00007ffff74a4a85 in QApplication::exec () at kernel/qapplication.cpp:2824 
      #76 0x000000000040130d in main (argc=<optimized out>, argv=<optimized out>) at /mnt/data/home/qydw/Develop/Test/ReuseItemsBug/main.cpp:21

       

       

      Attachments

        1. reproducible.mp4
          1018 kB
          Yuanzheng Wang
        2. ReuseItemsBug.tar-2.gz
          13 kB
          Yuanzheng Wang
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            qt.team.quick.subscriptions Qt Quick and Widgets Team
            fusionfuture Yuanzheng Wang
            Votes:
            2 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:
              Resolved:

              Gerrit Reviews

                There are no open Gerrit changes