Added CDockWidget feature to recreate widgets from a factory #365
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Sorry for the wall of text, since we talked about this before this is my attempt at making you understand the problem and why this feature is needed.
As we know, by default all widgets are supposed to be created at the start of the application and using the save states (or perspectives) the widgets are shown or hidden (and kept alive). I would say this is fine for most applications, but in more complex applications, it raises several problems:
The
DeleteOnCloseflag allows this deletion to happen, but with limitations. Using the flag, dock widgets are fully deleted and will lose all context about the place where they were spawned. This behavior is fine for widgets that always have a specific spawning area and that might be infinite in number; it is mainly intended for document widgets and it works wonderfully for that. For regular widgets though, this is not great at all, users expect the widget to reappear in the same place where they closed it.The new flag is intended to use the default capabilities of ADS and allow for application widgets to be deleted and recreated internally by the dock widgets themselves. This allows to keep the context of the dock widgets as usual, and save them and everything, while at the same time be able to delete and release the resources of these complex widgets. This improves memory usage of the application, allows the user to optimize it a bit and allows for a better debugging experience. Additionally, in my case it allows plugins to retain their position when they are installed or uninstalled, and appear in the same place with minimal impact.
This is a gif of it in action, I added a menu action in the

deleteonclosewithout modifying the other two actions to see how it behaves in comparison.