aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGregory Amerson2012-10-17 12:05:40 (EDT)
committerKonstantin Komissarchik2012-10-17 12:05:40 (EDT)
commit60ee1e3433b9704c8abd6f9e1eec57b0d29699f9 (patch)
tree5635396d6c126008a48345dbf6cb5393c75fa4d4
parentef1025ad8df65ccbfc09a1a052cf31a8c06a11a4 (diff)
downloadorg.eclipse.sapphire-60ee1e3433b9704c8abd6f9e1eec57b0d29699f9.zip
org.eclipse.sapphire-60ee1e3433b9704c8abd6f9e1eec57b0d29699f9.tar.gz
org.eclipse.sapphire-60ee1e3433b9704c8abd6f9e1eec57b0d29699f9.tar.bz2
Fix : NPE when accessing enablement of an overridden property
If a property is overridden, an NPE is thrown when calling IModelElement.enabled( ModelProperty ) method on the derived element using base element's property. Consider the following example model: public interface BaseElement extends IModelElement { ValueProperty PROP_VALUE = new ValueProperty( TYPE, "Value" ); ... } public interface DerivedElement extends BaseElement { ValueProperty PROP_VALUE = new ValueProperty( TYPE, BaseElement.PROP_VALUE ); ... } The following code snippet will produce an NPE: DerivedElement derived = DerivedElement.TYPE.instantiate(); boolean enabled = derived.enabled( BaseElement.PROP_VALUE ) ); java.lang.NullPointerException at org.eclipse.sapphire.modeling.ModelElement.enabled(ModelElement.java:584) at org.eclipse.sapphire.ui.renderers.swt.DefaultListPropertyEditorRenderer$AbstractColumnEditingSupport.canEdit(DefaultListPropertyEditorRenderer.java:1466) at org.eclipse.jface.viewers.ColumnViewerEditor.activateCellEditor(ColumnViewerEditor.java:165) at org.eclipse.jface.viewers.ColumnViewerEditor.handleEditorActivationEvent(ColumnViewerEditor.java:445) at org.eclipse.jface.viewers.ColumnViewer.triggerEditorActivationEvent(ColumnViewer.java:680) at org.eclipse.jface.viewers.ColumnViewer.handleMouseDown(ColumnViewer.java:664) at org.eclipse.jface.viewers.ColumnViewer.access$0(ColumnViewer.java:660) at org.eclipse.jface.viewers.ColumnViewer$1.mouseDoubleClick(ColumnViewer.java:94) https://bugs.eclipse.org/bugs/show_bug.cgi?id=392131
-rw-r--r--plugins/org.eclipse.sapphire.modeling/src/org/eclipse/sapphire/modeling/ModelElement.java8
1 files changed, 5 insertions, 3 deletions
diff --git a/plugins/org.eclipse.sapphire.modeling/src/org/eclipse/sapphire/modeling/ModelElement.java b/plugins/org.eclipse.sapphire.modeling/src/org/eclipse/sapphire/modeling/ModelElement.java
index dae1a87..a9334d5 100644
--- a/plugins/org.eclipse.sapphire.modeling/src/org/eclipse/sapphire/modeling/ModelElement.java
+++ b/plugins/org.eclipse.sapphire.modeling/src/org/eclipse/sapphire/modeling/ModelElement.java
@@ -573,12 +573,14 @@ public abstract class ModelElement extends ModelParticle implements IModelElemen
{
synchronized( root() )
{
- Boolean status = this.enablementStatuses.get( property );
+ final ModelProperty finalProperty = property.refine( this );
+
+ Boolean status = this.enablementStatuses.get( finalProperty );
if( status == null )
{
- refreshProperty( property, true );
- status = this.enablementStatuses.get( property );
+ refreshProperty( finalProperty, true );
+ status = this.enablementStatuses.get( finalProperty );
}
return status;