-
Notifications
You must be signed in to change notification settings - Fork 29
Correct the number entries in the many entries warning dialog #384
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Open
tuanvtdeptre199
wants to merge
1
commit into
eclipse-tracecompass:master
Choose a base branch
from
tuanvtdeptre199:fixnumberentries
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
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
Oops, something went wrong.
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.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Repository: eclipse-tracecompass/org.eclipse.tracecompass
Length of output: 50402
🏁 Script executed:
Repository: eclipse-tracecompass/org.eclipse.tracecompass
Length of output: 4964
🏁 Script executed:
rg -n 'IPreCheckStateListener|setPreCheckStateListener|fListener|listener\.' tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/dialogs/FilteredCheckboxTree.java -A 3 -B 3Repository: eclipse-tracecompass/org.eclipse.tracecompass
Length of output: 71
🏁 Script executed:
Repository: eclipse-tracecompass/org.eclipse.tracecompass
Length of output: 3834
🏁 Script executed:
rg -n 'setSubtreeChecked\|IPreCheckStateListener' tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/dialogs/TriStateFilteredCheckboxTree.java -B 5 -A 10Repository: eclipse-tracecompass/org.eclipse.tracecompass
Length of output: 71
🏁 Script executed:
Repository: eclipse-tracecompass/org.eclipse.tracecompass
Length of output: 5285
🏁 Script executed:
rg -n 'listener.*setSubtreeChecked|fListener|IPreCheckStateListener' tmf/org.eclipse.tracecompass.tmf.ui/src/org/eclipse/tracecompass/tmf/ui/widgets/timegraph/dialogs/ -B 3 -A 3Repository: eclipse-tracecompass/org.eclipse.tracecompass
Length of output: 4812
🏁 Script executed:
Repository: eclipse-tracecompass/org.eclipse.tracecompass
Length of output: 1118
🏁 Script executed:
Repository: eclipse-tracecompass/org.eclipse.tracecompass
Length of output: 4467
Line 51 undercounts by 1 due to pre-mutation callback timing.
The listener is invoked before
checkSubtree()mutates the checked state. When the formula computesgetCheckedElements().length + getSubTreeSize(element) - 1, it reads the pre-mutation count plus the subtree size (which includes the element itself), then subtracts 1—resulting inpre_count + descendantsinstead of the correct post-mutation total ofpre_count + 1 + descendants. This causes the boundary case (e.g., 20 checked + 1 leaf = 21 total) to be undercounted as 20, suppressing the warning whennb > 20should trigger. Remove the- 1offset.🤖 Prompt for AI Agents
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For example, in the "CPU Usage" view, when the user selects the parent node in the tree table ("kernel" node), the method
FilteredCheckboxTree.doCreateTreeViewer(Composite parentComposite, int style)will automatically hit and add the selected parent node into the fieldfCheckedObjects-> After that, the methodManyEntriesSelectedDialogPreCheckedListener.setSubtreeChecked(Object element, boolean state)is called, and at this moment,fFilteredCheckboxTree.getCheckedElements().lengthhas already counted theelementbefore, so we have to -1 to get the correct number selected entry before the user's action in the tree table.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🧩 Analysis chain
🏁 Script executed:
Length of output: 2541
🏁 Script executed:
Length of output: 11885
@tuanvtdeptre199, you are absolutely right, and I apologize for the incorrect review comment. After tracing the actual execution order in the code, your explanation is fully confirmed:Confirmed event flow:
CheckStateChangedEvent.FilteredCheckboxTree's listener fires first (registered insuper.doCreateTreeViewer()):TriStateFilteredCheckboxTree's listener fires second (registered in its owndoCreateTreeViewer()):setSubtreeChecked,getCheckedElements()already containselementat this point.This is also confirmed by the snapshot logic at the top of
setSubtreeChecked(lines 82–87), which explicitly callsprevChecked.remove(element)whenstate=true— precisely becauseelementis already infCheckedObjectsand needs to be excluded from the "before" snapshot for a potential revert.So the arithmetic is:
getCheckedElements().length= pre-action count +1 (element already included)getSubTreeSize(element)= 1 (element itself) + descendants- 1: double-counts the element → off by 1- 1:(pre_count + 1) + (1 + descendants) - 1=pre_count + 1 + descendants✓The fix is correct as written.
✏️ Learnings added
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I concur with @tuanvtdeptre199 (and AI bot eventually).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.