Yea, I wasn't aware of anything that would give you a list like this. I
always considered the ids the same as raw pointers. Basically, don't leak
them :-)
I like the idea Robert has of wrapping the ids into "smart" ids as in the
vein of RAII
<https://en.wikipedia.org/wiki/Resource_acquisition_is_initialization>

Shot in the dark, but maybe they don't expose a way to list the ids for the
reason that it would give people a chance to muck with other registered
callback? But, even if you could get a list of ids, what would you do with
them? Callbacks can be registered by both C++ and Python, which means the
callbacks would end up being opaque pointers to the caller.

Justin

On Tue, Apr 24, 2018 at 4:20 PM Robert White <robert.wd.wh...@gmail.com>
wrote:

> I'm not sure there is a simple way.
> I went looking the last time I was doing serious work with callbacks, and
> eventually just settled on wrapping them with my own custom classes that
> could handle de-registration as needed.
>
> The closest I could find was `MMessage.nodeCallbacks` which will return a
> list of callbacks associated with a node, but that won't track things like
> scene, ui, or other non-node based callbacks.
>
>
>
>
> On Monday, April 23, 2018 at 10:06:17 PM UTC-5, Marcus Ottosson wrote:
>>
>> Hi all,
>>
>> With the Maya Python API (both 1.0 and 2.0) you can register callbacks,
>> like so:
>>
>> from maya.api import OpenMaya as om
>> om.MDGMessage.addTimeChangeCallback(...)
>>
>> It’ll hand you an ID you can later use to deregister it.
>>
>> def myCallback(time, clientData):
>>    pass
>>
>> eventId = om.MDGMessage.addTimeChangeCallback(myCallback, None)
>> om.MMessage.removeCallback(eventId)
>>
>> But what do you do when you haven’t kept track of the ID? I’m debugging a
>> potential leak of events being registered but not unregistered and am
>> looking for something along the lines of..
>>
>> for func, eventId in om.MMessage.listCallbacks():
>>   print("EventID %d belongs to %s" % (func, eventId))
>> # EventID 153 belongs to 'myCallback'
>>
>> I’m also curious about what events are registered per default and by
>> third-party plug-ins or scripts and figure this would be an intuitive way
>> of finding out.
>>
>> How can I list all currently registered events?
>>
>> Thanks,
>> Marcus
>> ​
>>
> --
> You received this message because you are subscribed to the Google Groups
> "Python Programming for Autodesk Maya" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to python_inside_maya+unsubscr...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/python_inside_maya/3aa9077b-70c7-4607-a70c-aeeb1a53ee92%40googlegroups.com
> <https://groups.google.com/d/msgid/python_inside_maya/3aa9077b-70c7-4607-a70c-aeeb1a53ee92%40googlegroups.com?utm_medium=email&utm_source=footer>
> .
> For more options, visit https://groups.google.com/d/optout.
>

-- 
You received this message because you are subscribed to the Google Groups 
"Python Programming for Autodesk Maya" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to python_inside_maya+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/python_inside_maya/CAPGFgA3szE_D%3DsbzMoAdUm0Rihn7sm9hk_MJk-N4M%2B_tPgpPXw%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to