Change it from const wxString& to just wxString so there is no need to keep a copy around of untranslated strings.
This allows to remove thread_local UntranslatedStringHolder used by GetUntranslatedString, which causes many problems with MinGW.
Fixes #26195
https://github.com/wxWidgets/wxWidgets/pull/26196
(11 files)
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Looks good to me, thanks!
Pinging @vslavik just in case I'm forgetting any reason not to apply this.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Pinging @vslavik just in case I'm forgetting any reason not to apply this.
I don't remember the reasons for this code (maybe git blame can provide hints, but probably not after all that time), but the only ones I can think of are performance (seems unlikely though) and API compatibility back when we unified ANSI and Unicode builds. Plausibly the function returned wxChar* back then and there was a risk of it being stored. If wxGetTranslation returned a copy and its wxChar* conversion was implicitly called, there would be use-after-free.
I don't think this is concern nowadays.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Such a change needs to be documented as a potential incompatibility in Changes in behaviour not resulting in compilation errors.
For example, in our project there is in some places code like this
const wxString& GetText() const { return wxGetTranslation( ms_texts[m_index] ); }
that needs to be adapted accordingly.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
Good point. I mistakenly thought the changelog was only updated whenever a release is made, but incompatible changes should be added immediately.
Depending on settings, compilers do give a warning or error after this change, like:
error C2220: the following warning is treated as an error
warning C4172: returning address of local variable or temporary
But this is not the default, so putting it in Changes in behaviour not resulting in compilation errors seems correct to me.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()
I thought compilers would warn about this but if they don't, this change is worse than I thought :-( It's probably still not enough to revert it.
I'll add a note to the changelog.
—
Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.![]()