I have seen two causes of malloc errors crashing Python
1) when using a grid and setting an attribute to a cell or column, you need to remember to issue and IncRef() call for the attribute otherwise wx will lose track of how many times the attr object is being used
2) this one is tougher for me to explain because I don't fully understand what I do wrong; maybe I will try to together a sample and post it. When putting together widgets and sizers, if you do it wrong, it is possible to get into a situation where the same widget is a child twice in the same hierarchy. When the hierarchy is destroyed / freed that widget is freed twice and crashes Python on the second free. You can see the problem by using the Inspection tool, but it might be hard to find in a complicated application.
Hope these give some useful hints.
--
Mike Conley
--
To unsubscribe, send email to wxPython-user...@googlegroups.com
or visit http://groups.google.com/group/wxPython-users?hl=en
There are two fundamentally different ways to use threads in GUI programs and either way has to take care of the fact that the GUI library itself usually is not multi-threading safe, i.e. that it might crash if two threads try to access the GUI class simultaneously. One way to prevent that is have a normal GUI program in the main thread and some worker threads which work in the background.Cheers and good luck with your fixing. Hopefully, wx.CallAfter will do the trick for you. It has been invaluable for me.
I learned about the rudiments of wx.CallAfter for multithreaded GUI
projects from some conversations on this list, and it has been
serving me well.
I have two questions related to that, and appropriate usage.
1) When doing some graphicsDC work, I am using wx.CallAfter for
drawing commands with good success. I'm wondering it is appropriate
to use wx.CallAfter() isolation for ALL cmds that interact with the
DC or does it make sense only for one's which result in visible GUI
changes.
ie. Do I need to CallAfter for all these dc interactions:
wx.CallAfter(dc.BeginDrawing)
wx.CallAfter(dc.SetPen, wx.Pen('GREEN'))
wx.CallAfter(dc.DrawRectangle, bw, bh, RectWide, RectHi)
or only for
wx.CallAfter(dc.DrawRectangle, bw, bh, RectWide, RectHi)
as that last call is the only one that effects a display change?
2) Let's say I have two GUI interacting routines DrawSomething() and
MkDwgChanges() that are both in my app thread, and I occasionally
call MkDwgChanges() from another thread.
I use wx.CallAfter() wrappers in my MkDwgChanges() routine so that it
will not cause cross-thread collision crashes. But will those
wx.CallAfter()'s cause any concerns when they are called within in
the Thread0 execution? ie where they are not strictly needed because
they are in the non-cross-threaded context with the wx GUI widgets in
the same thread?
Thanks in advance for any help on understanding those Q's.
Regards,
Ross.
yup - you never quote know what might cause problems -- AY wx cal should
be in the main thread.
> ie. Do I need to CallAfter for all these dc interactions:
>
> wx.CallAfter(dc.BeginDrawing)
> wx.CallAfter(dc.SetPen, wx.Pen('GREEN'))
> wx.CallAfter(dc.DrawRectangle, bw, bh, RectWide, RectHi)
usually those are done all together, in a single method, so it would be
only one CallAfter to call that method.
In fact, particularly for dc.BeginDrawing, you realy wouldn't want all
the other stuff called in separate events.
> But will those
> wx.CallAfter()'s cause any concerns when they are called within in the
> Thread0 execution?
no -- CallAfter is not a thread-specific =call -- it is just a thread
safe one. What it does is put an event on the event stack that will call
your function when it reaches the top (bottom?) of the stack. There are
often uses for it even within a single thread.
-Chris
--
Christopher Barker, Ph.D.
Oceanographer
Emergency Response Division
NOAA/NOS/OR&R (206) 526-6959 voice
7600 Sand Point Way NE (206) 526-6329 fax
Seattle, WA 98115 (206) 526-6317 main reception
Ross.