dabo Commit Revision 1276 Date: 2005-09-09 04:08:27 -0700 (Fri, 09 Sep 2005) Author: ed
Changed:
U trunk/dabo/ui/uiwx/dPemMixin.py
Log:
Fixed copy/paste error that would sometimes cause an infinite loop.
Diff:
Modified: trunk/dabo/ui/uiwx/dPemMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dPemMixin.py 2005-09-09 06:00:04 UTC (rev 1275)
+++ trunk/dabo/ui/uiwx/dPemMixin.py 2005-09-09 11:08:27 UTC (rev 1276)
@@ -1079,6 +1079,10 @@
# Parent could be None, or currentName
wasn't bound yet (init)
pass
+ # Make sure that the name isn't already used
+ if self.Parent:
+ if hasattr(self.Parent, name):
+ raise NameError, "Name '%s' is
already in use." % name
try:
self.Parent.__dict__[name] = self
except AttributeError:
@@ -1093,16 +1097,16 @@
# the name if necessary to make it
unique (we don't want a NameError).
i = 0
while True:
- nameError = False
if i == 0:
candidate = name
else:
candidate = "%s%s" %
(name, i)
-
- for window in
parent.GetChildren():
- if window.GetName() ==
candidate and window != self:
- nameError = True
- break
+ nameError = hasattr(parent,
candidate)
+ if not nameError:
+ for window in
parent.GetChildren():
+ if
window.GetName() == candidate and window != self:
+
nameError = True
+ break
if nameError:
i += 1
else:
@@ -1111,9 +1115,12 @@
else:
# the user is explicitly setting the
Name. If another object already
# has the name, we must raise an
exception immediately.
- for window in parent.GetChildren():
- if str(window.GetName()) ==
str(name) and window != self:
- raise NameError, "Name
'%s' is already in use." % name
+ if hasattr(parent, name):
+ raise NameError, "Name '%s' is
already in use." % name
+ else:
+ for window in
parent.GetChildren():
+ if
str(window.GetName()) == str(name) and window != self:
+ raise
NameError, "Name '%s' is already in use." % name
else:
# Can't do the name check for siblings, so
allow it for now.
_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
