@Circuits said in Q_INVOKABLE funciton returning null when called in QML 'onDestruction':
Is there a way to test if the object itself is null from the QML?
The test is the same as for any variable. if (! obj) tests for null or undefined. Using an explicit !== null also works. Presumably the object in this case is this, but getting into the situation where this === null is something you probably want to avoid.
I have a workaround. I created two states: open, closed and a property:
property string prevState: ""
whenever the state changes I set the previous state to be the current state that way I can identify when the state is changing from open to closed and in that instance I can call the methods.
However, while this works it doesn't explain how to deal with the QMl calling an object which is null.
Without code, I can't suggest anything better than if (this) { do_something(); }, which looks like a work around for a deeper problem.