more fixes to want-direct startup sequence

This commit is contained in:
David Rose 2007-02-22 20:03:00 +00:00
parent 8eb5baa427
commit 290f49c761

View File

@ -65,6 +65,7 @@ class ShowBase(DirectObject.DirectObject):
vfs = VirtualFileSystem.getGlobalPtr() vfs = VirtualFileSystem.getGlobalPtr()
self.nextWindowIndex = 1 self.nextWindowIndex = 1
self.__directStarted = False
# Store dconfig variables # Store dconfig variables
self.sfxActive = self.config.GetBool('audio-sfx-active', 1) self.sfxActive = self.config.GetBool('audio-sfx-active', 1)
@ -197,7 +198,7 @@ class ShowBase(DirectObject.DirectObject):
# Open the default rendering window. # Open the default rendering window.
if self.windowType != 'none': if self.windowType != 'none':
self.openDefaultWindow() self.openDefaultWindow(startDirect = False)
self.loader = Loader.Loader(self) self.loader = Loader.Loader(self)
self.eventMgr = eventMgr self.eventMgr = eventMgr
@ -307,6 +308,9 @@ class ShowBase(DirectObject.DirectObject):
# This needs to be allocated even if the viewer is off. # This needs to be allocated even if the viewer is off.
self.bufferViewer = BufferViewer() self.bufferViewer = BufferViewer()
if self.windowType != 'none':
self.__doStartDirect()
# Start IGLOOP # Start IGLOOP
self.restart() self.restart()
@ -546,6 +550,10 @@ class ShowBase(DirectObject.DirectObject):
# startup. It is normally called automatically unless # startup. It is normally called automatically unless
# window-type is configured to 'none'. # window-type is configured to 'none'.
startDirect = kw.get('startDirect', True)
if 'startDirect' in kw:
del kw['startDirect']
self.openMainWindow(*args, **kw) self.openMainWindow(*args, **kw)
# Give the window a chance to truly open. # Give the window a chance to truly open.
@ -575,13 +583,8 @@ class ShowBase(DirectObject.DirectObject):
# error not to open a window. # error not to open a window.
raise StandardError, 'Could not open window.' raise StandardError, 'Could not open window.'
# Start Tk and DIRECT if specified by Config.prc if startDirect:
fTk = self.config.GetBool('want-tk', 0) self.__doStartDirect()
# Start DIRECT if specified in Config.prc or in cluster mode
fDirect = (self.config.GetBool('want-directtools', 0) or
(self.config.GetString("cluster-mode", '') != ''))
# Set fWantTk to 0 to avoid starting Tk with this call
self.startDirect(fWantDirect = fDirect, fWantTk = fTk)
return self.win != None return self.win != None
@ -2046,6 +2049,19 @@ class ShowBase(DirectObject.DirectObject):
else: else:
__builtins__["direct"] = self.direct = None __builtins__["direct"] = self.direct = None
def __doStartDirect(self):
if self.__directStarted:
return
self.__directStarted = False
# Start Tk and DIRECT if specified by Config.prc
fTk = self.config.GetBool('want-tk', 0)
# Start DIRECT if specified in Config.prc or in cluster mode
fDirect = (self.config.GetBool('want-directtools', 0) or
(self.config.GetString("cluster-mode", '') != ''))
# Set fWantTk to 0 to avoid starting Tk with this call
self.startDirect(fWantDirect = fDirect, fWantTk = fTk)
def profileNextFrame(self): def profileNextFrame(self):
self.taskMgr.profileNextFrame() self.taskMgr.profileNextFrame()