dabo Commit
Revision 6038
Date: 2010-09-29 22:15:23 -0700 (Wed, 29 Sep 2010)
Author: Paul
Trac: http://trac.dabodev.com/changeset/6038

Changed:
U   trunk/dabo/dReportWriter.py
U   trunk/dabo/ui/uiwx/__init__.py

Log:
Ever since introducing the report progress bar, I've received about 3 error
logs from customers per month with the 'wx.Yield called recursively' error,
and I've never been able to reproduce it on my end.

I did some Googling, and someone in May found a workaround that solved the
problem for him. I've added a _safe=False argument to dabo.ui.yieldUI: when
True, the new code is run. I changed the yieldUI() calls from dReportWriter
to yieldUI(_safe=True) to test it in the field. It doesn't seem to break
anything. I wanted to keep the argument "private" for now until it has a
track record, at which point it'll probably become the default code for
yieldUI().

Here's the link to the article I got the code from:
http://www.python-forum.org/pythonforum/viewtopic.php?f=4&t=18801



Diff:
Modified: trunk/dabo/dReportWriter.py
===================================================================
--- trunk/dabo/dReportWriter.py 2010-09-27 00:36:01 UTC (rev 6037)
+++ trunk/dabo/dReportWriter.py 2010-09-30 05:15:23 UTC (rev 6038)
@@ -54,14 +54,14 @@
                win = self.ProgressControl
                if win:
                        win.updateProgress(self.RecordNumber+1, 
len(self.Cursor))
-                       dabo.ui.yieldUI()
+                       dabo.ui.yieldUI(_safe=True)
 
        def _hideProgress(self):
                win = self.ProgressControl
                if win:
                        win.hide()
                        win.Form.fitToSizer()
-                       dabo.ui.yieldUI()
+                       dabo.ui.yieldUI(_safe=True)
 
        def _getEncoding(self):
                try:

Modified: trunk/dabo/ui/uiwx/__init__.py
===================================================================
--- trunk/dabo/ui/uiwx/__init__.py      2010-09-27 00:36:01 UTC (rev 6037)
+++ trunk/dabo/ui/uiwx/__init__.py      2010-09-30 05:15:23 UTC (rev 6038)
@@ -324,9 +324,14 @@
        return ret
 
 
-def yieldUI(*args, **kwargs):
+def yieldUI(_safe=False, *args, **kwargs):
        """Yield to other apps/messages."""
-       wx.Yield(*args, **kwargs)
+       if _safe:
+               while wx.GetApp().Pending():
+                       wx.GetApp().Dispatch()
+                       wx.GetApp().Yield(True)
+       else:
+               wx.Yield(*args, **kwargs)
 
 
 def beep():



_______________________________________________
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