fix: Add sort to prevent scope deleted by former iterations in for loop#1440
Open
liegle wants to merge 1 commit into
Open
fix: Add sort to prevent scope deleted by former iterations in for loop#1440liegle wants to merge 1 commit into
liegle wants to merge 1 commit into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Description
This pr aims to fix unexpected "Scope not in graph" error logs like this issue
Cause of the error log
In
notify_value_changed, when iteratingaffected_subsopes, listeners of those scopes processed first will remove scopes to be processed later, if that "later scope" is subscope of both currentscope_indexand oneaffected_subscopeiterated first, and thisaffected_subscopeis a for-loop scope.An example:
Scope relationship:
When calling
tree.notify_value_changed(0, "TEST"),1,3,5,7will be inaffected_subscopesbecause they all referenceTEST. When1is iterated,3,5,7will be removed, if any of them is iterated after this, the error log will be printed and the iteration will terminate. This will cause latter unremoved things impossible to be processed.Solution
Sort
affected_subscopesbefore iterating it, as scopes created latter will have larger indices.Additional
Maybe a better way to fix it is not to set superscopes of widget definitions to root scope in
build_basic_gtk_widget. But I don't known why it was written like this and wonder if is it good to change it.Checklist
no widgets added
no need
docs/content/maindirectory has been adjusted to reflect my changes.no need
cargo fmtto automatically format all code before committing