diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonComponentWalker.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonComponentWalker.cs index 38dde5c74f..be74c87c92 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonComponentWalker.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonComponentWalker.cs @@ -301,10 +301,7 @@ namespace ICSharpCode.PythonBinding /// object GetCurrentComponent() { - if (fieldExpression.VariableName.Length > 0) { - return componentCreator.GetComponent(fieldExpression.VariableName); - } - return component; + return fieldExpression.GetObject(componentCreator); } /// diff --git a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlFieldExpression.cs b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlFieldExpression.cs index 48305ccf12..2716231232 100644 --- a/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlFieldExpression.cs +++ b/src/AddIns/BackendBindings/Python/PythonBinding/Project/Src/PythonControlFieldExpression.cs @@ -177,6 +177,17 @@ namespace ICSharpCode.PythonBinding return names.ToArray(); } + /// + /// Gets the object that the field expression variable refers to. + /// + public object GetObject(IComponentCreator componentCreator) + { + if (variableName.Length > 0) { + return componentCreator.GetComponent(variableName); + } + return componentCreator.RootComponent; + } + /// /// Returns the object that the property is defined on. This method may just return the object /// passed to it if the property is defined on that object. @@ -192,6 +203,9 @@ namespace ICSharpCode.PythonBinding object currentComponent = component; for (int i = startIndex; i < members.Length - 1; ++i) { PropertyDescriptor propertyDescriptor = TypeDescriptor.GetProperties(currentComponent).Find(members[i], true); + if (propertyDescriptor == null) { + return null; + } currentComponent = propertyDescriptor.GetValue(currentComponent); } return currentComponent;