mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-04 02:42:49 -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
|
# Set a flag so we will stop before beginning next frame
|
||||||
self.running = 0
|
self.running = 0
|
||||||
|
|
||||||
def replaceMethod(self, oldMethod, newFunction):
|
def __tryReplaceTaskMethod(self, task, oldMethod, newFunction):
|
||||||
import new
|
import new
|
||||||
for taskPriList in self.taskList:
|
if (task is None) or task.isRemoved():
|
||||||
for task in taskPriList:
|
return 0
|
||||||
if (task is None) or (task.isRemoved()):
|
|
||||||
break
|
|
||||||
method = task.__call__
|
method = task.__call__
|
||||||
if (type(method) == types.MethodType):
|
if (type(method) == types.MethodType):
|
||||||
function = method.im_func
|
function = method.im_func
|
||||||
@ -895,10 +893,25 @@ class TaskManager:
|
|||||||
method.im_self,
|
method.im_self,
|
||||||
method.im_class)
|
method.im_class)
|
||||||
task.__call__ = newMethod
|
task.__call__ = newMethod
|
||||||
# Found it return true
|
# Found a match
|
||||||
return 1
|
return 1
|
||||||
return 0
|
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):
|
def __repr__(self):
|
||||||
taskNameWidth = 32
|
taskNameWidth = 32
|
||||||
dtWidth = 10
|
dtWidth = 10
|
||||||
|
Loading…
x
Reference in New Issue
Block a user