[Bf-python] Remove a modal handler from the window manager

"Martin Bürbaum" martin.buerbaum at gmx.at
Tue Feb 28 14:37:34 CET 2012


Dan Eicher <dan at trollwerks.org> wrote:

> Somewhere in VIEW3D_OT_display_measurements there needs to be a check
> for canceling the drawing operation which then calls:
> 
> ...region.callback_remove(self._handle)
> 
> -- perhaps in modal() which calls a dedicated function to loop over
> all the windows/regions and clean this stuff up.

Ok, after some investigation I've found out that I can not remove the callback in modal(). At the time the add-on is unregistered the modal handler doesn't run anymore.

And if I use e.g. __del__ I have the wrong context and _handle is not set. :-(
Same problem if I use execute/invoke from anywhere in the code.
	
Furthermore I have searched for other, similar implementations and e.g. the space_view3d_screencast_keys script does not handle unregistering as well. There might be no display anymore, but the callback draw_callback_px() is still running.
So at least I know I'm not the only one with this exact problem.

The example implementations I've found remove the callback before unregistering, so the issue doesn't pop up there.

Cheers,
Martin



More information about the Bf-python mailing list