Browse Source

default values not allowed as parent tokens

Darren Ranalli 19 years ago
parent
commit
6c46fccb42
1 changed files with 7 additions and 1 deletions
  1. 7 1
      direct/src/distributed/ParentMgr.py

+ 7 - 1
direct/src/distributed/ParentMgr.py

@@ -1,6 +1,7 @@
 """ParentMgr module: contains the ParentMgr class"""
 
 from direct.directnotify import DirectNotifyGlobal
+from direct.showbase.PythonUtil import isDefaultValue
 
 class ParentMgr:
     # This is now used on the AI as well.
@@ -24,7 +25,7 @@ class ParentMgr:
     """
 
     notify = DirectNotifyGlobal.directNotify.newCategory('ParentMgr')
-    
+
     def __init__(self):
         self.token2nodepath = {}
         # these are nodepaths that have requested to be parented to
@@ -64,6 +65,8 @@ class ParentMgr:
                               (repr(child), parentToken))
             child.wrtReparentTo(self.token2nodepath[parentToken])
         else:
+            if isDefaultValue(parentToken):
+                self.notify.error('child %s requested reparent to default-value token: %s' % (repr(child), parentToken))
             self.notify.debug(
                 "child %s requested reparent to parent '%s' that is not (yet) registered" %
                 (repr(child), parentToken))
@@ -83,6 +86,9 @@ class ParentMgr:
                 "registerParent: token '%s' already registered, referencing %s" %
                 (token, repr(self.token2nodepath[token])))
 
+        if isDefaultValue(token):
+            self.notify.error('parent token (for %s) cannot be a default value (%s)' % (repr(parent), token))
+
         self.notify.debug("registering %s as '%s'" % (repr(parent), token))
         self.token2nodepath[token] = parent