I have a component that when instantiated in a client (ie on a componentRunning property event script) will create an global instance of a python class defined in one of my script modules (shared.testing). The event script will pass a reference to the component that instantiated the class to the new class instance.
shared.testing I have:
def MyClass: parentComponent = None classInstance = MyClass()
In the component propertyChange event script I have:
if event.propertyName == 'componentRunning': if event.newValue: shared.testing.classInstance.parentComponent = event.source
Later in time I want the class instance to set a property value of the parent component.
shared.testing.classInstance.parentComponent.someProperty = someValue
But I first want to check if the reference to the parent component is still valid. Is this possible? If so, how?
I plan to clear the reference on the same property change event script.
if event.propertyName == 'componentRunning': if not event.newValue: shared.testing.classInstance.parentComponent = None
But I still want to verify the reference. Just in case.