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

QAbstractItemModelTester with resetModel and fetchMore false positive result

XMLWordPrintable

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

      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.

       

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

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

              Created:
              Updated:

                There are no open Gerrit changes