showbase: Fix an entire DirectSession being (re)created on node selection

Closes #1051
This commit is contained in:
Daniel 2020-11-14 02:09:25 +02:00 committed by rdb
parent f1ca8a9018
commit 7eba53cffa

View File

@ -157,6 +157,7 @@ class ShowBase(DirectObject.DirectObject):
self.wantStats = self.config.GetBool('want-pstats', 0)
self.wantTk = False
self.wantWx = False
self.wantDirect = False
#: Fill this in with a function to invoke when the user "exits"
#: the program by closing the main window.
@ -3270,7 +3271,12 @@ class ShowBase(DirectObject.DirectObject):
def startDirect(self, fWantDirect = 1, fWantTk = 1, fWantWx = 0):
self.startTk(fWantTk)
self.startWx(fWantWx)
if self.wantDirect == fWantDirect:
return
self.wantDirect = fWantDirect
if self.wantDirect:
# Use importlib to prevent this import from being picked up
# by modulefinder when packaging an application.