Skip to content

Update model tester handling around hasChildren() #420

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 28, 2022
Merged

Update model tester handling around hasChildren() #420

merged 1 commit into from
Apr 28, 2022

Conversation

The-Compiler
Copy link
Member

Relevant upstream changes:

QAbstractItemModelTester: don't rely on hasChildren()
https://codereview.qt-project.org/c/qt/qtbase/+/318767

Dynamic models which use fetchMore to asynchronously fill subdirs
(like KDirModel) return true in hasChildren() for dirs that are expected
to have children (so that the "+" shows in the treeview) but do not
actually have children readily available.
They will be inserted later on once the async listing job is done
(as a result of fetchMore triggering that job).

So QAbstractItemModelTester should use rowCount instead, to find out
if there are children present.

This detected a bug in QConcatenateTablesProxyModel: it returned
a non-zero rowCount for its items, while it's flat.

QAbstractItemModelTester: fix false positive when model has zero columns
https://codereview.qt-project.org/c/qt/qtbase/+/341238
https://bugreports.qt.io/browse/QTBUG-92220

Fix QAbstractItemModelTester false positive
https://codereview.qt-project.org/c/qt/qtbase/+/343539
https://bugreports.qt.io/browse/QTBUG-92886

When rows are removed from a model with no columns,
the test should not report a problem if indexes are invalid

Fix QAbstractItemModelTester false positive
https://codereview.qt-project.org/c/qt/qtbase/+/345195

When inserting rows to a branch with no columns
the tester should not complain about indexes being invalid

Still missing one bigger change which I plan to do separately:

Add tests to QAbstractItemModelTester checking only one change in flight (I15fe1ad1) · Gerrit Code Review

Relevant upstream changes:

QAbstractItemModelTester: don't rely on hasChildren()
https://codereview.qt-project.org/c/qt/qtbase/+/318767

    Dynamic models which use fetchMore to asynchronously fill subdirs
    (like KDirModel) return true in hasChildren() for dirs that are expected
    to have children (so that the "+" shows in the treeview) but do not
    actually have children readily available.
    They will be inserted later on once the async listing job is done
    (as a result of fetchMore triggering that job).

    So QAbstractItemModelTester should use rowCount instead, to find out
    if there are children present.

    This detected a bug in QConcatenateTablesProxyModel: it returned
    a non-zero rowCount for its items, while it's flat.

QAbstractItemModelTester: fix false positive when model has zero columns
https://codereview.qt-project.org/c/qt/qtbase/+/341238
https://bugreports.qt.io/browse/QTBUG-92220

Fix QAbstractItemModelTester false positive
https://codereview.qt-project.org/c/qt/qtbase/+/343539
https://bugreports.qt.io/browse/QTBUG-92886

    When rows are removed from a model with no columns,
    the test should not report a problem if indexes are invalid

Fix QAbstractItemModelTester false positive
https://codereview.qt-project.org/c/qt/qtbase/+/345195

    When inserting rows to a branch with no columns
    the tester should not complain about indexes being invalid
Copy link
Member

@nicoddemus nicoddemus left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Took a glance at the patches you posted (thanks for the detailed description, as always) and the code changes, everything LGTM. 👍

@The-Compiler
Copy link
Member Author

Build failures are unrelated (see #419), merging this so I can submit part 2 😉

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants