[wx-dev] Re: wxString(s.c_str()) thread safety (was Re: wxString threadsafe)

Vadim Zeitlin vadim at wxwidgets.org
Fri May 2 05:25:24 PDT 2008


On Fri, 02 May 2008 14:20:13 +0200 Robert Roebling wrote:

RR> Vadim Zeitlin wrote:
RR> 
RR> > Hajo Kirchhoff wrote:
RR> > 
RR> > HK> So my strong wish for wxWidgets 2.9 and up would be to have a thread 
RR> > HK> safe wxString class by default.
RR> > 
RR> > On most platforms this would be achieved by simply making wxUSE_STL=1
RR> > the default so it's another argument in its favour.
RR> 
RR> I must be the only one who overlooked this. But anyway, what is this
RR> an argument for: remove reference counting from the non-STL based
RR> wxString, use STL, not use STL? 

 I'd say "use STL". Except that I'm very afraid that this will result in
major problems with wx 3.0 adoption because of c_str() problem (which is
far more serious than all the minor incompatibilities introduced so far).

RR> Having a thread-safe wxString class in STL mode and one that is not
RR> thread-safe and has (very?) different performance characteristics in
RR> non-STL mode doesn't look optimal.

 Yes, so I guess we should replace our wxString implementation with a
non-reference counted version using small string optimization (this is what
all modern STL implementations use AFAIK).

RR> > Of course, with wxUSE_STL=1 we don't have implicit c_str() any longer
RR> > which is a problem on its own :-(
RR> 
RR> What is the problem with that?

 Tons of existing code which won't compile any longer. Just try building
wxDesigner with wxUSE_STL=1.

 Of course, fixing this is trivial but the sheer amount of errors you get
will probably put off quite a few people from upgrading. So while I still
think that wxUSE_STL should become the default I'm afraid it's a bad idea
to do it in 3.0. 3.2 or 4.0 maybe.

 Regards,
VZ



More information about the wx-dev mailing list