Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 320960

Summary: CanonicalConnectionEditPolicy#isOrphaned throws NullPointerException if model is corrupt
Product: [Modeling] GMF-Runtime Reporter: Linda Damus <ldamus>
Component: GeneralAssignee: Linda Damus <ldamus>
Status: RESOLVED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: aboyko, ahunter.eclipse, lgrahek
Version: 1.4.0   
Target Milestone: 1.4.1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
Proposed fix. none

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.