Modal Operator not shuting down -- Possible memory leak?

A small add-on test case found at

creates a NodeTree, where a TestNode with a button to start a Modal Operator can be added.

pushing the button invokes the operator ->

execute adds a timer and adds the operator to the window_manager ->

operator receives events.

So far so good.

but when the node is destroyed and a signal to destroy the operator is sent through a shared object the operator still receives events.

Is this supposed to happen? When is the operator destroyed?

Using CANCELED instead of CANCELLED as the return value may explain the problem.

Would have been nice – blender seems too ignore the return value –
even when I return not so nice values.

Thanks for finding the typo :wink: it was in the cancel method not in the destroy method :wink:

Once the Operator has reached it’ modal method it is only reacting to values returned by this method.

Possible return values are::
(‘RUNNING_MODAL’, ‘CANCELLED’, ‘FINISHED’, ‘PASS_THROUGH’, ‘INTERFACE’)

Yes, it’s ‘CANCELLED’ with two L

so the if clause in the modal method should read:

if self.Node_Context_ww_Data[“Destroy”]:
self.j = self.j +1
ret = self.destroy(context)
return ret

then the operator receives a couple of events (2 - 4) and then it exits gracefully