mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-02 09:52:27 -04:00
*** empty log message ***
This commit is contained in:
parent
3fb67aef60
commit
d249ff24e5
@ -125,10 +125,12 @@ def copyFuncs(fromClass, toClass):
|
||||
newFunc = value
|
||||
# See if we already have a function with this name
|
||||
if toClass.__dict__.has_key(key):
|
||||
# Look in the messenger to see if this old function pointer
|
||||
# is stored, and update it to the new function pointer
|
||||
# Look in the messenger and taskMgr to see if this
|
||||
# old function pointer is stored there,
|
||||
# and update it to the new function pointer
|
||||
oldFunc = toClass.__dict__[key]
|
||||
replaceMessengerFunc(oldFunc, newFunc)
|
||||
replaceTaskMgrFunc(oldFunc, newFunc)
|
||||
toClass.__dict__[key] = newFunc
|
||||
|
||||
def replaceMessengerFunc(oldFunc, newFunc):
|
||||
@ -136,3 +138,7 @@ def replaceMessengerFunc(oldFunc, newFunc):
|
||||
if res:
|
||||
print ('replaced messenger function: ' + newFunc.__name__)
|
||||
|
||||
def replaceTaskMgrFunc(oldFunc, newFunc):
|
||||
res = taskMgr.replaceMethod(oldFunc, newFunc)
|
||||
if res:
|
||||
print ('replaced taskMgr function: ' + newFunc.__name__)
|
||||
|
@ -290,6 +290,27 @@ class TaskManager:
|
||||
# Set a flag so we will stop before beginning next frame
|
||||
self.running = 0
|
||||
|
||||
def replaceMethod(self, oldMethod, newFunction):
|
||||
import new
|
||||
for task in self.taskList:
|
||||
method = task.__call__
|
||||
if (type(method) == types.MethodType):
|
||||
function = method.im_func
|
||||
else:
|
||||
function = method
|
||||
#print ('function: ' + `function` + '\n' +
|
||||
# 'method: ' + `method` + '\n' +
|
||||
# 'oldMethod: ' + `oldMethod` + '\n' +
|
||||
# 'newFunction: ' + `newFunction` + '\n')
|
||||
if (function == oldMethod):
|
||||
newMethod = new.instancemethod(newFunction,
|
||||
method.im_self,
|
||||
method.im_class)
|
||||
task.__call__ = newMethod
|
||||
# Found it retrun true
|
||||
return 1
|
||||
return 0
|
||||
|
||||
def __repr__(self):
|
||||
str = ''
|
||||
str = str + 'taskList\n'
|
||||
|
Loading…
x
Reference in New Issue
Block a user