From 0cf605ce7df868d7ec06d421480ef8ee0dd32094 Mon Sep 17 00:00:00 2001 From: rdb Date: Fri, 23 Feb 2018 21:26:49 +0100 Subject: [PATCH] showbase: move run() and __dev__ to ShowBaseGlobal Also remove ShowBaseGlobal notify category, it doesn't really add anything --- direct/src/showbase/ShowBase.py | 8 +++----- direct/src/showbase/ShowBaseGlobal.py | 9 ++++++--- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/direct/src/showbase/ShowBase.py b/direct/src/showbase/ShowBase.py index 580f2b6ce7..8e3c223000 100644 --- a/direct/src/showbase/ShowBase.py +++ b/direct/src/showbase/ShowBase.py @@ -47,10 +47,6 @@ if __debug__: from . import OnScreenDebug from . import AppRunnerGlobal -def legacyRun(): - assert builtins.base.notify.warning("run() is deprecated, use base.run() instead") - builtins.base.run() - @atexit.register def exitfunc(): if getattr(builtins, 'base', None) is not None: @@ -369,7 +365,6 @@ class ShowBase(DirectObject.DirectObject): builtins.bboard = self.bboard # Config needs to be defined before ShowBase is constructed #builtins.config = self.config - builtins.run = legacyRun builtins.ostream = Notify.out() builtins.directNotify = directNotify builtins.giveNotify = giveNotify @@ -391,7 +386,9 @@ class ShowBase(DirectObject.DirectObject): # Now add this instance to the ShowBaseGlobal module scope. from . import ShowBaseGlobal + builtins.run = ShowBaseGlobal.run ShowBaseGlobal.base = self + ShowBaseGlobal.__dev__ = self.__dev__ if self.__dev__: ShowBase.notify.debug('__dev__ == %s' % self.__dev__) @@ -515,6 +512,7 @@ class ShowBase(DirectObject.DirectObject): # Remove the built-in base reference if getattr(builtins, 'base', None) is self: + del builtins.run del builtins.base del builtins.loader del builtins.taskMgr diff --git a/direct/src/showbase/ShowBaseGlobal.py b/direct/src/showbase/ShowBaseGlobal.py index 1f1c81af1a..c18ebab5fc 100644 --- a/direct/src/showbase/ShowBaseGlobal.py +++ b/direct/src/showbase/ShowBaseGlobal.py @@ -14,6 +14,7 @@ from panda3d.core import ConfigPageManager, ConfigVariableManager from panda3d.direct import get_config_showbase config = get_config_showbase() +__dev__ = config.GetBool('want-dev', __debug__) vfs = VirtualFileSystem.getGlobalPtr() ostream = Notify.out() @@ -25,6 +26,10 @@ pandaSystem = PandaSystem.getGlobalPtr() # Set direct notify categories now that we have config directNotify.setDconfigLevels() +def run(): + assert ShowBase.notify.warning("run() is deprecated, use base.run() instead") + base.run() + def inspect(anObject): # Don't use a regular import, to prevent ModuleFinder from picking # it up as a dependency when building a .p3d package. @@ -41,6 +46,4 @@ builtins.inspect = inspect # this also appears in AIBaseGlobal if (not __debug__) and __dev__: - notify = directNotify.newCategory('ShowBaseGlobal') - notify.error("You must set 'want-dev' to false in non-debug mode.") - del notify + ShowBase.notify.error("You must set 'want-dev' to false in non-debug mode.")