Skip to content
  • Eike Hein's avatar
    When used by QML, only populate after component is complete · b40c0de0
    Eike Hein authored
    Summary:
    This introduces the use of QQmlParserStatus to delay populating
    the model until all properties have been set, to avoid delegate
    churn.
    
    TasksModel is also meant to be used by C++. There's no good way
    to determine whether an object is being instanciated by QML
    during construction time, therefore this patch also introduces a
    delay in initial population of the model after construction via
    a single-shot timer. At the time the slot is invoked we know if
    we're used by QML (because QQmlParserStatus::classBegin has
    either been called or not by then) so we can decide to populate
    or wait more for QQmlParserStatus::componentComplete.
    
    I'm not super happy with this behavior change for C++ users,
    however as the model is usually used via QML currently, it's
    pragmatic to optimize performance for the common case, and it
    doesn't technically break QAbstractItemModel semantics, as model
    population isn't required to be sync.
    
    There's a decent change this fixes a recently-reported crash as a
    by-product:
    CCBUG:386630
    
    Reviewers: #plasma, davidedmundson, mart
    
    Subscribers: plasma-devel
    
    Tags: #plasma
    
    Differential Revision: https://phabricator.kde.org/D8723
    b40c0de0