[?? Probable Spam] wxString threadsafe?
mailinglists
mailinglists at hajo-kirchhoff.de
Sun Apr 20 07:46:20 PDT 2008
Thanks for the responses.
> cannot share a wxString between =
> m> threads.
> m> =
> m> Is this still true?
>
> Yes.
>
> m> I am using AddPendingEvent to post a wxString object from one thread t=
o =
> m> another and was under the impression that this is a safe thing to do.
>
> No, it isn't. You need to use s.c_str() or something like this to ensure
> that the string is really copied when you use it with AddPendingEvent() a=
nd
> not just shared.
> =
That will not work either. If I use s.c_str() and pass it to =
AddPendingEvent, AddPendingEvent will still create a wxString from the =
c_str() and then _that_ string is shared between threads. The crash will =
still occur, although more rarely (I've tried it).
If wxString is not threadsafe, one cannot use AddPendingEvent at all to =
pass a wxString.
The only safe way I see is to create a wxString (or C-String) on the =
heap, cast the pointer to an integer, pass that integer to =
AddPendingEvent. Or create my own event containing a std::string or char*.
> m> If wxString is still not thread safe then a note at both wxString and =
> m> AddPendingEvent mentioning this would certainly be appreciated
>
> We probably should mention this more prominently somewhere but it's not
> clear where to put it to make sure it's easy to notice...
> =
How about both in the wxString and the AddPendingEvent documentation.
Best regards
Hajo
> Regards,
> VZ
>
> -- TT-Solutions: wxWidgets consultancy and technical support =
> http://www.tt-solutions.com/ =
> _______________________________________________ wx-users mailing list =
> wx-users at lists.wxwidgets.org =
> http://lists.wxwidgets.org/mailman/listinfo/wx-users
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.wxwidgets.org/pipermail/wx-users/attachments/20080420/ed5=
714c3/attachment.htm
More information about the wx-users
mailing list