dabo Commit
Revision 6908
Date: 2011-10-20 16:44:15 -0700 (Thu, 20 Oct 2011)
Author: Paul
Trac: http://trac.dabodev.com/changeset/6908

Changed:
U   trunk/dabo/ui/uiwx/dSizerMixin.py

Log:
I spent literally all afternoon chasing down a segmentation fault/illegal 
instruction
in my code, and it turns out a copy/paste error added the same sizer twice:

187     vs.append(hs, "expand")
188     
189     hs.appendSpacer((2,0))
190     hs.append(dabo.ui.dCheckBox(self, ##DataSource="ord_misc", 
##DataField="enabled",
191         Name="chkEnabled", Caption="Enabled"), "expand")
192     hs.appendSpacer((20,0))
193     vs.append(hs, "expand")

Notice that in 187 I append hs, and I again append it in 193. Obviously, I had 
meant to create a new instance of hs in 188, but I didn't notice because the 
form
displayed okay. It was only when closing the application that the segfault
would occur. 

So, given that a simple check in the sizer insert() code would have saved me all
this grief, I offer these two lines to my future self and hopefully others, too.


Diff:
Modified: trunk/dabo/ui/uiwx/dSizerMixin.py
===================================================================
--- trunk/dabo/ui/uiwx/dSizerMixin.py   2011-10-20 23:28:01 UTC (rev 6907)
+++ trunk/dabo/ui/uiwx/dSizerMixin.py   2011-10-20 23:44:15 UTC (rev 6908)
@@ -122,6 +122,8 @@
        def insert(self, index, obj, layout="normal", proportion=0, 
alignment=None,
                        halign="left", valign="top", border=None, 
borderSides=None):
                """Inserts the passed object into the sizer layout at the 
specified position."""
+               if obj in self.ChildSizers:
+                       raise ValueError, _("Adding the same sizer twice is not 
allowed.")
                if isinstance(layout, int):
                        # proportion was passed first
                        layout, proportion = proportion, layout



_______________________________________________
Post Messages to: [email protected]
Subscription Maintenance: http://leafe.com/mailman/listinfo/dabo-dev
Searchable Archives: http://leafe.com/archives/search/dabo-dev
This message: 
http://leafe.com/archives/byMID/[email protected]

Reply via email to