diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index dfc7d450bb..260f65718b 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -175,6 +175,7 @@ class ShowBase(DirectObject.DirectObject): self.camLens = None self.camFrustumVis = None self.direct = None + self.wxApp = None # This is used for syncing multiple PCs in a distributed cluster try: @@ -2713,7 +2714,32 @@ class ShowBase(DirectObject.DirectObject): if self.wantWx: initAppForGui() from direct.showbase import WxGlobal - WxGlobal.spawnWxLoop() + self.spawnWxLoop() + + def spawnWxLoop(self): + if self.wxApp: + # Don't do this twice. + return + + import wx + # Create a new base.wxApp. + self.wxApp = wx.PySimpleApp(redirect = False) + + # Set a timer to run the Panda frame 60 times per second. + self.wxTimer = wx.Timer(self.wxApp) + self.wxTimer.Start(1000.0/60.0) + self.wxApp.Bind(wx.EVT_TIMER, self.__wxTimerCallback) + + # wx is now the main loop, not us any more. + self.run = self.wxRun + self.taskMgr.run = self.wxRun + __builtin__.run = self.wxRun + + def __wxTimerCallback(self, event): + self.taskMgr.step() + + def wxRun(self): + self.wxApp.MainLoop() def startTk(self, fWantTk = True): fWantTk = bool(fWantTk) diff --git a/direct/src/showbase/WxGlobal.py b/direct/src/showbase/WxGlobal.py index 9e465219c7..ae2e618102 100755 --- a/direct/src/showbase/WxGlobal.py +++ b/direct/src/showbase/WxGlobal.py @@ -1,22 +1,4 @@ -import wx -from direct.task.Task import Task - -def wxLoop(self): - # First we need to ensure that the OS message queue is processed. - base.wxApp.Yield() - - # Now do all the wxPython events waiting on this frame. - while base.wxApp.Pending(): - base.wxApp.Dispatch() - - return Task.cont +""" This module is now vestigial. """ def spawnWxLoop(): - if not getattr(base, 'wxApp', None): - # Create a new base.wxApp, but only if it's not already - # created. - base.wxApp = wx.PySimpleApp(redirect = False) - - # Spawn this task - taskMgr.remove('wxLoop') - taskMgr.add(wxLoop, "wxLoop") + base.spawnWxLoop() diff --git a/panda/src/event/asyncTaskChain.cxx b/panda/src/event/asyncTaskChain.cxx index c71d745369..e8bc5bd7a8 100644 --- a/panda/src/event/asyncTaskChain.cxx +++ b/panda/src/event/asyncTaskChain.cxx @@ -1268,12 +1268,14 @@ do_poll() { return; } -#ifndef NDEBUG if (_num_busy_threads != 0) { - nassert_raise("You may not recursively invoke the TaskManager from within a task"); + // We are recursively nested within another task. Return quietly. + if (task_cat.is_debug()) { + task_cat.debug() + << "Ignoring recursive poll() within another task.\n"; + } return; } -#endif nassertv(!_pickup_mode);