mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-03 18:31:55 -04:00
task replacement now looks for doLaters and pending tasks
This commit is contained in:
parent
6c5a9f0309
commit
7fefe01e6a
@ -875,12 +875,10 @@ class TaskManager:
|
||||
# Set a flag so we will stop before beginning next frame
|
||||
self.running = 0
|
||||
|
||||
def replaceMethod(self, oldMethod, newFunction):
|
||||
def __tryReplaceTaskMethod(self, task, oldMethod, newFunction):
|
||||
import new
|
||||
for taskPriList in self.taskList:
|
||||
for task in taskPriList:
|
||||
if (task is None) or (task.isRemoved()):
|
||||
break
|
||||
if (task is None) or task.isRemoved():
|
||||
return 0
|
||||
method = task.__call__
|
||||
if (type(method) == types.MethodType):
|
||||
function = method.im_func
|
||||
@ -895,10 +893,25 @@ class TaskManager:
|
||||
method.im_self,
|
||||
method.im_class)
|
||||
task.__call__ = newMethod
|
||||
# Found it return true
|
||||
# Found a match
|
||||
return 1
|
||||
return 0
|
||||
|
||||
def replaceMethod(self, oldMethod, newFunction):
|
||||
numFound = 0
|
||||
# Look through the regular tasks
|
||||
for taskPriList in self.taskList:
|
||||
for task in taskPriList:
|
||||
numFound += self.__tryReplaceTaskMethod(task, oldMethod, newFunction)
|
||||
# Look through the pending tasks
|
||||
for pri, taskList in self.pendingTaskDict.items():
|
||||
for task in taskList:
|
||||
numFound += self.__tryReplaceTaskMethod(task, oldMethod, newFunction)
|
||||
# Look through the doLaters
|
||||
for task in self.__doLaterList:
|
||||
numFound += self.__tryReplaceTaskMethod(task, oldMethod, newFunction)
|
||||
return numFound
|
||||
|
||||
def __repr__(self):
|
||||
taskNameWidth = 32
|
||||
dtWidth = 10
|
||||
|
Loading…
x
Reference in New Issue
Block a user