Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 320960 - CanonicalConnectionEditPolicy#isOrphaned throws NullPointerException if model is corrupt
Summary: CanonicalConnectionEditPolicy#isOrphaned throws NullPointerException if model...
Status: RESOLVED FIXED
Alias: None
Product: GMF-Runtime
Classification: Modeling
Component: General (show other bugs)
Version: 1.4.0   Edit
Hardware: PC Windows XP
: P3 normal
Target Milestone: 1.4.1   Edit
Assignee: Linda Damus CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2010-07-26 16:33 EDT by Linda Damus CLA
Modified: 2010-07-30 13:19 EDT (History)
3 users (show)

See Also:


Attachments
Proposed fix. (1.40 KB, patch)
2010-07-27 09:29 EDT, Linda Damus CLA
no flags Details | Diff

Note You need to log in before you can comment on or make changes to this bug.
Description Linda Damus CLA 2010-07-26 16:33:39 EDT
Please consider making the CanonicalConnectionEditPolicy#isOrphaned method tolerate corrupt models where the source or target of a connection cannot be resolved.  This would allow the cannonical edit policy to create a new connection view to replace the one that is corrupt, since the semantic model is still intact.

Proposed fix:

protected boolean isOrphaned(Collection<EObject> semanticChildren, View view) {
   EObject element = view.getElement();
   if (semanticChildren.contains(element)) {
      if (view instanceof Edge) {
         Edge edge = (Edge) view;
         if ((edge.getSource() == null || 
                   (edge.getSource().getElement() != getSourceElement(element)))
             || (edge.getTarget() == null || 
                   (edge.getTarget().getElement() != getTargetElement(element))))
            return true;
         }
      } else {
         return true;
      }
      return false;
   }
}
Comment 1 Linda Damus CLA 2010-07-27 09:29:24 EDT
Created attachment 175311 [details]
Proposed fix.
Comment 2 Anthony Hunter CLA 2010-07-28 16:57:43 EDT
Alex, Lidija, can one of you review?
Comment 3 Alex Boyko CLA 2010-07-28 17:19:22 EDT
Looks good to me.
Comment 4 Linda Damus CLA 2010-07-30 13:19:20 EDT
Committed to GMF Runtime HEAD (1.5.0) and GMF Runtime R1_4_maintenance.