Skip to content
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

Fix 'Move selected to top' breaks attribute table sorting #58901

Conversation

benwirf
Copy link
Contributor

@benwirf benwirf commented Sep 29, 2024

Description

Recently I noticed that toggling the 'Move selected to top' action in the attribute table dialog, breaks any existing sort column and sort order; the sorting is always reset to ascending on the first column.

Looking at the code, it seems that the sort column and order was hard-coded to 0 and Qt::AscendingOrder respectively. The existing sort column and order is retrieved but not used:

Screenshot from 2024-09-29 16-56-50

Unless I'm missing something, shouldn't we be passing the column and order values to the sort() call?

Screencast before:

selected-to-top-bug-1

Screencast after proposed fix:

selected-to-top-bug-2

…ttribute table dialog

breaks the current sort column and sort order due to the column and order being
hard-coded to 0 and Qt::AscendingOrder respectively.
@github-actions github-actions bot added this to the 3.40.0 milestone Sep 29, 2024
Copy link

github-actions bot commented Sep 29, 2024

🪟 Windows builds ready!

Windows builds of this PR are available for testing here. Debug symbols for this build are available here.

(Built from commit 9fa7b44)

@agiudiceandrea agiudiceandrea added Bug Either a bug report, or a bug fix. Let's hope for the latter! backport queued_ltr_backports Queued Backports backport release-3_34 and removed backport queued_ltr_backports Queued Backports labels Sep 29, 2024
@nyalldawson
Copy link
Collaborator

Good catch! Looking through the git history, it seemed a bunch of cleanups have happened to this function over time which resulted in the current bug.

Would you be able to extend the tests in TestQgsAttributeTable::testSelectedOnTop() to cover this fix too?

@benwirf
Copy link
Contributor Author

benwirf commented Sep 30, 2024

No worries @nyalldawson, can do. I will have a look after work.

@benwirf
Copy link
Contributor Author

benwirf commented Sep 30, 2024

Tests added. I think this is enough to adequately test the bug fix, but it's been a long day so hopefully I haven't made any blunders in checking the feature orders!

@nyalldawson
Copy link
Collaborator

Great work, thanks @benwirf !

@nyalldawson nyalldawson merged commit b9ad6ac into qgis:master Sep 30, 2024
28 checks passed
@benwirf
Copy link
Contributor Author

benwirf commented Sep 30, 2024

Thanks @nyalldawson! :-)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport queued_ltr_backports Queued Backports Bug Either a bug report, or a bug fix. Let's hope for the latter!
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants