Community
Participate
Working Groups
Build Identifier: 20100218-1602 The generated getNavigatorSelection method in ???DiagramEditor.java does not check for null diagram or resource. This can be a problem when we are implementing diagram partitioning with shared editing domain as described in http://wiki.eclipse.org/GMF_Tips#Sharing_single_EditingDomai n_instance_across_several_diagrams. In this case we can have a null resource and then a java.lang.NullPointerException will occur when getNavigatorSelection calls WorkspaceSynchronizer.getFile passing null. In order to fix this, we could manually change the generated code as shown below, but it is better to fix the original template used to generated it. private ISelection getNavigatorSelection() { ... Diagram diagram = document.getDiagram(); // Modification started. if (diagram == null || diagram.eResource() == null) { return StructuredSelection.EMPTY; } // Modification ended. IFile file = WorkspaceSynchronizer.getFile(diagram.eResource()); ... } This has been discussed in the following forum message: http://www.eclipse.org/forums/index.php?t=rview&goto=559558&th=175421#msg_559558 Reproducible: Always Steps to Reproduce: 1. Generate the diagram code from a gmfgen file. 2. Open the generated ???DiagramEditor.java file. 3. Look for the getNavigatorSelection method.
Created attachment 183007 [details] Proposed patch This patch should add the necessary check and avoid the NPE.
Comment on attachment 183007 [details] Proposed patch Although it's not apparent how come shared editing domain leads to null resource for a diagram, the null check seems to be appropriate there.
committed.
version -> 2.4
Rollback, Set target to 2.4 instead of accidenatlly set Version