Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 341259 - [JFace] Add debug flag to find bad content providers that return multiple equal children
Summary: [JFace] Add debug flag to find bad content providers that return multiple equ...
Status: VERIFIED FIXED
Alias: None
Product: Platform
Classification: Eclipse Project
Component: UI (show other bugs)
Version: 3.7   Edit
Hardware: All All
: P3 enhancement (vote)
Target Milestone: 3.7 M7   Edit
Assignee: Markus Keller CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2011-03-29 13:05 EDT by Markus Keller CLA
Modified: 2011-10-06 04:29 EDT (History)
3 users (show)

See Also:


Attachments
Fix (9.19 KB, patch)
2011-03-30 14:22 EDT, Markus Keller CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Markus Keller CLA 2011-03-29 13:05:31 EDT
Follow-up to bug 327004

The "Widget is disposed" exception from bug 327004 (and all the other similar bugs that could not be reproduced) has been traced back to two possible error conditions in the while-loop in AbstractTreeViewer#updateChildren(*):
- data could be null (should AFAIK not happen)
- the tree content provider returned multiple equal children for a parent node

At least for the second problem, we should add a debug flag in JFace to make it easier for clients to find such problems.

The patch from bug 327004 comment 6 already implemented such a message, but instead of only logging the problem in that specific error condition, the message should be written for *all* cases where this could happen. We could add the optional check to StructuredViewer#getRawChildren(Object) and all overriding methods, or probably even broader in StructuredViewer#assertElementsNotNull(Object).

The latter should be called wherever children are fetched from a content provider (but it's missing is some places like AbstractTreeViewer#getRawChildren(Object)).
Comment 1 Markus Keller CLA 2011-03-30 14:22:22 EDT
Created attachment 192217 [details]
Fix

- adds the org.eclipse.jface/debug/viewers/equalElements debug option (disabled by default)
- fixes debug option support in JFaceUtil
- adds missing assertElementsNotNull(*) to AbstractTreeViewer
Comment 2 Markus Keller CLA 2011-03-30 14:23:17 EDT
Fixed in HEAD.
Comment 3 Markus Keller CLA 2011-04-27 08:42:35 EDT
Verified in I20110426-2000.
Comment 4 Dani Megert CLA 2011-10-06 04:29:49 EDT
The change in ui.workbench didn't make it into the 4.x stream. Manually cherry-picked now:
Commit 2295bf6c7372f559353bb09ca40750d8d93f3448