LumaPictures / pymel

Python in Maya Done Right
Other
490 stars 131 forks source link

missing callBackId #289

Open pmolodo opened 9 years ago

pmolodo commented 9 years ago

From kjelle.a...@gmail.com on August 23, 2011 07:04:13

I get the following error:

// Error: line 0: (kInvalidParameter): No element at given index
# Traceback (most recent call last):
pymel/core/**init**.py", line 105, in addPluginPyNodes
#     _api.MEventMessage.removeCallback( id )
# RuntimeError: (kInvalidParameter): No element at given index // 
// Warning: line 0: Failed to call script callback // 

PyMel tries to remove a callback but the callback ID does not exist anymore. This happens when I

  1. import pymel.core as pm
  2. load a scene which requires a plugin which loads several nodes
  3. open a new file (even when just creating an empty scene)

It does not happen when I load the plugin manually before loading the file.

This is the PyMel code:

        def addPluginPyNodes(*args):
            try:
                id = _pluginData[pluginName]['callbackId']
                if id is not None:
                    _api.MEventMessage.removeCallback( id )
                    if hasattr(id, 'disown'):
                        id.disown()

I added this line to fix this issue:

_pluginData[pluginName]['callbackId'] = None

I don't really understand why the addPluginPyNodes is called when the callback is not there anymore...

Maya version: 2011.5x64 OS: Red Hat 5.3, 64bits PyMel: 1.0.3

Original issue: http://code.google.com/p/pymel/issues/detail?id=255