Community
Participate
Working Groups
Steps To Reproduce: (1) Create a new extension point schema (2) Create a new element (3) Delete the new element's name by making the "Name" field empty (4) Switch to the source page (5) Switch back to the "Definition" form page -> BUG: NPE produced (see below) At this point everything goes haywire because the model is corrupt. There are two problems here: (1) The form page allows the user to specify an empty element name -> If the user specifies an empty field name, we should revert it back to a previous valid value (perhaps when the focus is lost?) (2) The schema model does not guard against empty names on load -> We should guard against NPEs java.lang.NullPointerException at org.eclipse.pde.internal.core.schema.Schema.processElement(Schema.java:646) at org.eclipse.pde.internal.core.schema.Schema.traverseDocumentTree(Schema.java:923) at org.eclipse.pde.internal.core.schema.Schema.load(Schema.java:391) at org.eclipse.pde.internal.core.schema.Schema.reload(Schema.java:783) at org.eclipse.pde.internal.ui.editor.schema.SchemaInputContext.synchronizeModel(SchemaInputContext.java:160) at org.eclipse.pde.internal.ui.editor.context.InputContext.synchronizeModelIfNeeded(InputContext.java:360) at org.eclipse.pde.internal.ui.editor.context.InputContext.isModelCorrect(InputContext.java:382) at org.eclipse.pde.internal.ui.editor.XMLSourcePage.canLeaveThePage(XMLSourcePage.java:27) at org.eclipse.ui.forms.editor.FormEditor.pageChange(FormEditor.java:478) at org.eclipse.pde.internal.ui.editor.PDEFormEditor.pageChange(PDEFormEditor.java:290)
Created attachment 73782 [details] patch With this patch, when the attribute name and element name fields lose focus, their text will be reverted to the previous contents if they are empty. This will leave the editor in a dirty state even if it was not previously similarly to pressing the escape key. I have opened bug 196520 to address the issue of the escape key leaving the editor dirty. When there is a fix available for that, it should be applied to this case as well. This patch also marks the schema model as invalid if any element or attribute names are empty when it is built. This results in the user being unable to leave the source page if they enter an empty name.
Based on bug 196520 comment 1, it is fine that this patch leaves the editor in a dirty state after reverting the name.
Comment on attachment 73782 [details] patch Excellent patch, Adam. Thanks.
Patch applied to HEAD. Target: 3.4 M1
Unfortunately, the patch causes compositors not to be loaded correctly. Upon closer inspection one method is being used to process both elements and element references so null is a valid value for the "name" attribute if an element reference is being processed. Sorry Adam, I should have caught this.
Created attachment 73889 [details] patch correcting the problem This patch is to be applied on top of the previous one. It corrects the compositor loading problem. The processElement method is split into processElementReference and processElementDeclaration to avoid confusion in the future.
Comment on attachment 73889 [details] patch correcting the problem Tested well, Adam. Thanks.
Patch released to HEAD.