Repository navigation
Conversation
| scrollWid = 0; | ||
| } else { | ||
| setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOn); | ||
| QListWidgetItem *draggedItem = takeItem(selectedIndexes().first().row()); |
There was a problem hiding this comment.
Note
This is in context of commit 4dbc053. As stated in our contribution guidelines, all commits need to be "atomic" and represent a whole unit of change.
Just so I understand the logic right:
- You first take a pointer to the first of all selected items (because one could select multiple non-consecutive items and drag them).
- What is the order of items in the list returned by
selectedIndexes()? Is it order of actual selection or ordered by their row numbers in the original data model?
- What is the order of items in the list returned by
- Then you insert just this single item after the
lastTargetRow, which will be-1by default, thus representing the top of the list. - Then you set the inserted item as the "current" item (so it is selected by default, which will also trigger a whole lot of other "selection changed" events, scene changes, etc.)
At a cursory glance (and proven by testing this code change), this leads to an endless loop: There is always a selected item in the scene list, so you take the current item and reinsert it at the first position.
This triggers the resizeEvent again, which... reinserts the same item and triggers the resizeEvent, and on and on it goes until it corrupts the stack pointer.
At the same time this also triggers scene switch events over and over again. With just two scenes I get this in my log:
info: User switched to scene 'Scene 2'
info: User switched to scene 'Scene'
info: User switched to scene 'Scene 2'
info: User switched to scene 'Scene'
info: User switched to scene 'Scene 2'
info: User switched to scene 'Scene'
And that's just from switching to "Grid Mode" without any reordering involved.
There was a problem hiding this comment.
The signal blocker should be preventing that sort of recursion. I'll investigate.
There was a problem hiding this comment.
Right, but it looks like commit 4dbc053 leaves the project in a broken state because only a later commit introduces the signal blocker changes. So you'd have to squash these commits to ensure that you still end up in a working state e.g. during bisecting.
There was a problem hiding this comment.
Ah okay, are you saying that commit has these issues or the PR as a whole exhibits this infinite loop? I was probably gonna squash the commits.
There was a problem hiding this comment.
Ah okay, are you saying that commit has these issues or the PR as a whole exhibits this infinite loop? I was probably gonna squash the commits.
Yeah squashing them in the right way will probably resolve this automatically. But per our contribution guidelines I'm checking code commit by commit as that's the expectation for initial (and final) reviews.
There was a problem hiding this comment.
In regards to the actual problem itself:
At a cursory glance (and proven by testing this code change), this leads to an endless loop: There is always a selected item in the scene list, so you take the current item and reinsert it at the first position.
Welcome to the wonderful world of Current Behaviour! We were getting lucky before by offloading this logic into the resizeEvent. Reordering scenes in grid mode on stable actually switches to the scene in the index after the dragged item, and then immediately back to the dragged item. Code that works vs code that doesn't break etc.
Commits have been squashed and should be properly atomic now.
There was a problem hiding this comment.
Will give it another quick spin, though IIRC it all worked on the last commit before.
45ddfed to
2410de9
Compare
Moves the grid recalculation behaviour into a dedicated function instead of performing it as part of resizeEvent and manually triggering resizeEvents. This event is not always fired when you might expect, and triggering a resizeEvent manually can have unintended side effects. This blocks signals during the recalculation to ensure there is no potential for recursive resizeEvent churn. Fixes an issue on stable where reordering scenes in grid mode actually switches to the scene at the index after the dragged item, and then immediately back to the dragged item, when dropping the dragged item.
This eventFilter is empty and does nothing. I am unsure what it's purpose was as it has always been empty.
An old QTBUG allowed the scene to be deselected by clicking in the empty area of the QList. This was fixed at some point, however it is still possible to deselect the scene by clicking and dragging in the empty area now sooo we need this guard again.
Polish the widget instead of setting/clearing a stylesheet.
2410de9 to
4c87c38
Compare
Description
A medley of clean up to the SceneTree widget.
Pile o' commits:
Motivation and Context
Originally I was trying to chase down a UI deadlock a friend ran into when changing scenes. In the DMP I received from them, the main thread was stuck inside the SceneTree's drag event. I have yet to determine if the SceneTree was actually responsible in any way for that lock up, but looking around at what could have potentially caused it led me to the resizeEvent stuff.
How Has This Been Tested?
Tested all the functionality I changed. Reordered scenes in grid mode, adjusted the scene tree styling locally. Resized the dock before and after reordering items. Ensured Multiview behaved correctly in list and grid mode when making changes.
Types of changes
Checklist: