Add window refresh lock to block window from updating while handler is running. #2955
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.
When a handler is running it may add a lot of widgets to a window. The window keeps updating its layout, leading to an O(n^2) in calls to the
refresh()
function. When the number of widgets added to a window is doubled, run time is quadrupled (etc).This leads to slow updates when going from view to view.
My solution is to keep a list of 'dirty' children when a window is locked, so that the children will receive a
refresh()
call when the window is unlocked. Also, a window is automatically locked when a handler is called that has awindow
in its interface. No interaction from the user or application programmer is needed to use this functionality.PR Checklist: