Browse Source

enforce a single ShowBase

David Rose 14 years ago
parent
commit
303b51198e
1 changed files with 4 additions and 0 deletions
  1. 4 0
      direct/src/showbase/ShowBase.py

+ 4 - 0
direct/src/showbase/ShowBase.py

@@ -303,6 +303,10 @@ class ShowBase(DirectObject.DirectObject):
                 # Windows XP supports a 32-bit affinity mask
                 TrueClock.getGlobalPtr().setCpuAffinity(1 << (affinity % 32))
 
+        # Make sure we're not making more than one ShowBase.
+        if hasattr(__builtin__, 'base'):
+            raise StandardError, "Attempt to spawn multiple ShowBase instances!"
+        
         __builtin__.base = self
         __builtin__.render2d = self.render2d
         __builtin__.aspect2d = self.aspect2d