mirror of
https://github.com/panda3d/panda3d.git
synced 2025-10-01 17:35:34 -04:00
invert the WxGlobal loop: now wx owns the main loop, it seems to like that a lot better.
This commit is contained in:
parent
e08f1d204f
commit
93d625845c
@ -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)
|
||||
|
@ -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()
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user