[wx-dev] Re: wxString(s.c_str()) thread safety (was Re:
wxString threadsafe)
Robert Roebling
robert at roebling.de
Fri May 2 05:05:25 PDT 2008
Hajo Kirchhoff wrote:
> Hajo Kirchhoff schrieb:
> [...]
>
> > And so on. I will now eliminate wxString from the interfaces of all
> > worker thread classes, so that they either accept a TCHAR* or are using
> > std::basic_string<TCHAR>. The alternative would be a meticuously code
> > reading to examine every occurrence of wxString, determining if it might
> > be shared between threads. Just one copy, even a temporary one, is
> > enough to corrupt the heap.
>
> No, not even that is enough. If I pass a TCHAR* to a method and assign
> it to a member wxString, I still have the wxString-sharing problem.
I don't know what you mean here, but if we don't remove
reference counting from wxString (and this probably won't
happen as reference counting is not useless) the correct
way to have a wxString in the interface would probably
be something like this
wxString MyWorkerThread::Foo()
{
wxMutexLocker lock( m_stringMutex );
return m_mystring.Clone();
}
Robert
More information about the wx-dev
mailing list