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

QAbstractItemModelTester with resetModel and fetchMore false positive result

    XMLWordPrintable

Details

    • Bug
    • Resolution: Unresolved
    • P3: Somewhat important
    • None
    • 6.4.0
    • Core: Item Models
    • None
    • Linux/X11, Windows

    Description

      I've found an issue with QAbstractItemModelTester which reports false-positive result when beginResetModel/endResetModel and fetchMore is used.

       A tester is added to the Fetch More Example (https://doc.qt.io/qt-6/qtwidgets-itemviews-fetchmore-example.html) project:

       

      [[maybe_unused]]QAbstractItemModelTester*modelTester=newQAbstractItemModelTester
       (&m_model,QAbstractItemModelTester::FailureReportingMode::Fatal, this);
      //modelTester->setUseFetchMore(false);
      m_model.setDirPath("/home/bv"); 

       

      On application launch, I get a fault:

      Actual (changeInFlight) 5

      Expected (ChangeInFlight::None) 0

      (/home/qt/work/qt/qtbase/src/testlib/qabstractitemmodeltester.cpp:768)

       

      A debugging process showed me the following:

      1. User calls beginResetModel() and the tester sets internal changeInFlight value to ModelReset.

      2. User calls endResetModel() and tester calls runAllTests() function.

      3. runAllTests calls fetchMore() which calls beginInsertRows().

      4. In rowsAboutToBeInserted() slot tester checks if changeInFlight is None (line 768), but it is ModelReset!

      If I uncomment "modelTester->setUseFetchMore(false);" string, the bug dissapears.

      Files with code are attached.

       

      Attachments

        1. mainwindow.cpp
          2 kB
        2. mainwindow.h
          0.9 kB
        No reviews matched the request. Check your Options in the drop-down menu of this sections header.

        Activity

          People

            peppe Giuseppe D'Angelo
            borisvin Boris Vintenko
            Votes:
            1 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated:

              Gerrit Reviews

                There are no open Gerrit changes