浏览代码

enforce a single ShowBase

David Rose 14 年之前
父节点
当前提交
303b51198e
共有 1 个文件被更改,包括 4 次插入0 次删除
  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