Skip to content

Apoptose dock area when temporary window is closed#3134

Merged
j9ac9k merged 2 commits intopyqtgraph:masterfrom
UsYer:fix-redocked-dock-restorestate-failure
Oct 13, 2024
Merged

Apoptose dock area when temporary window is closed#3134
j9ac9k merged 2 commits intopyqtgraph:masterfrom
UsYer:fix-redocked-dock-restorestate-failure

Conversation

@UsYer
Copy link
Copy Markdown
Contributor

@UsYer UsYer commented Aug 25, 2024

After the fix for #2887 was introduced floating temp areas were not removed anymore when it was closed.
This lead to a TypeError when calling saveState and then restoreState, because it tried to restore half-present floating windows.
Now the apoptose method of the temporary area of the floating window is called explicitly in its closeEvent method.
This leads to a duplicate call to dock_area.apoptose only in the case when a floating window is closed by calling restoreState on the original dock area. In that case an exception would be raised be removeArea, because the temporary dock_area was alread removed,
This is handled by setting the reference to the original dock area to None in the dock_areas apoptose method, which breaks the cycle.
Introduced regression tests for #2887 and #3125 as well as another potential failure case discovered while trying to fix the issue.
Fixes #3125

UsYer added 2 commits August 25, 2024 23:54
 After the fix for pyqtgraph#2887 was introduced floating temp areas were not removed anymore when it was closed.
 This lead to a TypeError when calling saveState and then restoreState, because it tried to restore half-present floating windows.
 Also introduced regression tests for pyqtgraph#2887 and pyqtgraph#3125 as well as another potential failure case discovered while trying to fix the issue.
 Fixes pyqtgraph#3125
propagate was set to False to prevent the unintended collapse of a container tree with a single dock in a container.
But this lead to temporary areas closing anymore.
Instead, the removal of superfluous or empty containers is now only triggered by calling apoptose on the container if one of these cases is really present.
A unit test where this problem was discovered is added.
@UsYer
Copy link
Copy Markdown
Contributor Author

UsYer commented Sep 8, 2024

I found another case where preventing the propagation of apoptose calls leads to temporary areas not being closed and therefore breaking restoreState functionality.
If one drags the dock from the temporary area back into the main area the temporary window needs to close.
But I now found a way to reintroduce the propagation by only calling the containers apoptose method if it is needed during restoreState.
I added a unittest for this case.

@j9ac9k
Copy link
Copy Markdown
Member

j9ac9k commented Oct 13, 2024

Thank you @UsYer for this PR, and patching up the dock functionality. This part of the library doesn't get as much attention as others, so it's always refreshing to know contributors are using it and even better, making contributions to fix it up.

I apologize for the long duration from when you made this PR to me following up, life just gets in the way... Anyway, merging!

@j9ac9k j9ac9k merged commit b91d708 into pyqtgraph:master Oct 13, 2024
@MariusMeyerDraeger
Copy link
Copy Markdown

Thanks for reviewing and merging the PR.
I can imagine that the effort to maintain this package is a significant burden besides your regular life, so thanks a bunch for that!

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.

DockArea's restoreState is broken when a Dock was undocked and re-docked before calling saveState

3 participants