wxDC usage in a thread
Harry
"harry dot news at armadillo dot fr" at a.mx.sunsite.dk
Wed Feb 6 05:31:11 PST 2008
Hi,
I've encountered memory corruption errors when allocating wxDC on the
stack in a thread,
although in theory that's supposed to be possible.
After hours of debug, I've finally found the problem in the definition
of class wxDCBase in dc.h,
which specifies the following member initialization:
, m_backgroundBrush(*wxTRANSPARENT_BRUSH)
As the stock item wxTRANSPARENT_BRUSH is probably already allocated by
and used by
the main thread, its concurrent usage from a thread may destroy its
reference counting,
since reference counting isn't thread-safe.
I've solved the problem by replacing this member initialization by:
, m_backgroundBrush()
Does anybody have an objection to this, before I contribute it as a patch ?
Regards
Harry
More information about the wx-users
mailing list