Yan Wu wrote: > Hello Andreas, > >>> >>> If changes like above, there will be no necessary to change the define >>> of Class SvtUserOptions. >>> How do you think of above changes comparing the incompatible changes? >> >> No - you shouldnt use "const String&" as return value ever. >> It's never a good idea to return a reference to an internal member or >> variable. You cant make sure that those variable will live for the same >> time then it's used outside. >> >> BTW: Returning a string by value isnt a performance problem (as you >> might think) ... because our string classes uses a ref count mechanism. >> So the internal buffer will be shared between different string variables >> referring the same content ... till you change one instance. Then a new >> buffer will be created automaticly. >> >> So please use "String SvtUserOptions::GetXXX() const" for all methods >> you will find, where "const String& Svt.." was used before. >> It's no problem doing so ... it's an incompatible change (right) ... but >> it's an important refactoring to make OOo more stable. >> > > Now I have such two problems when using "String SvtUserOptions::GetXXX()": > 1)All the functions of OOo will be disable after OOo starts.(Please see > the image in the attachment I captured.) I debugged it but didnt find > the cause. > > 2)I removed the output trees(wntmsci10.pro) of modules desktop,svx and > sfx2 then build the three modules. But the compiler would not break > during the building process.(svtools has been built/delivered before > builing desktop,svx,sfx2.) Should the compiler break?
If you changed "const String& GetX()" to "String GetX()" no errors should happen at compile time. There's only one possible problem: if the returned reference was stored as reference somewhere. This code now would keep a reference to a temporary object and surely will crash later when it uses the reference. I'm not sure if any of our compilers will create a compiler warning for this, if we are lucky one of them does. This could be another good reason to switch to "::rtl::OUString GetX()" as IMHO assigning an ::rtl::OUString to a String& should create a compile time error on all platforms. Andreas, what do you think? Ciao, Mathias -- Mathias Bauer (mba) - Project Lead OpenOffice.org Writer OpenOffice.org Engineering at Sun: http://blogs.sun.com/GullFOSS Please don't reply to "[EMAIL PROTECTED]". I use it for the OOo lists and only rarely read other mails sent to it. --------------------------------------------------------------------- To unsubscribe, e-mail: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]