Skip to content

Use QAbstractListModel for dock tabs instead of QVariant (#26009 & #29188) - #29249

Merged
mathesoncalum merged 1 commit into
musescore:masterfrom
mathesoncalum:29188-qvariant_for_listmodel
Aug 21, 2025
Merged

mathesoncalum merged 1 commit into
musescore:masterfrom
mathesoncalum:29188-qvariant_for_listmodel

Conversation

@mathesoncalum

Copy link
Copy Markdown
Contributor

Resolves: #26009
Resolves: #29188

See my comment in #28912 for an explainer of the problem. The changes in this PR should allow for a more granular approach where we can modify individual contextMenu and toolBarComponent properties without resetting the entire tabs model.

cbjeukendrup

This comment was marked as resolved.

@mathesoncalum
mathesoncalum force-pushed the 29188-qvariant_for_listmodel branch from aeddc7f to 6d587f2 Compare August 15, 2025 14:53
@mathesoncalum
mathesoncalum marked this pull request as ready for review August 15, 2025 14:54
}
}

Component.onDestruction: { root.tabsModel.clear() }

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Why is this necessary?

@mathesoncalum mathesoncalum Aug 15, 2025 •

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

It may not be, but previously we called Component.onDestruction: { tabs.model = 0 } and I figured this was for good reason...

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@igorkorsukov It looks like you originally added it in 7d70f61. Do you by chance remember why?
Otherwise we might want to test what happens when we remove it.

@igorkorsukov igorkorsukov Aug 18, 2025 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I don't remember exactly, but I can guess.
When Qml is destroyed, the Qml objects themselves can remain "alive", especially for ListView delegates, maybe because of the cache, maybe the garbage collector will just work later... But I probably needed the navigation controls to unregister themselves immediately.
This is an assumption.

from this logic, the point of this code was not to clear the model, but to clear ListView specifically, so that it would delete all its delegates.

@zacjansheski

Copy link
Copy Markdown
Contributor

Tested on MacOS 15, Windows 11, Ubuntu 22.04.3. Approved
#29188 FIXED
#26009 FIXED

@mathesoncalum
mathesoncalum merged commit dea6831 into musescore:master Aug 21, 2025
@mathesoncalum
mathesoncalum deleted the 29188-qvariant_for_listmodel branch August 21, 2025 09:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

4 participants