Change return type of wxGetTranslation (PR #26196)

49 views
Skip to first unread message

Maarten

unread,
Feb 15, 2026, 4:20:23 PMFeb 15
to wx-...@googlegroups.com, Subscribed

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


You can view, comment on, or merge this pull request online at:

  https://github.com/wxWidgets/wxWidgets/pull/26196

Commit Summary

  • 02cff90 Change return type of wxGetTranslation
  • 6db1182 Fix building with wxUSE_INTL disabled

File Changes

(11 files)

Patch Links:


Reply to this email directly, view it on GitHub, or unsubscribe.
You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26196@github.com>

VZ

unread,
Feb 15, 2026, 8:45:32 PMFeb 15
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26196)

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.Message ID: <wxWidgets/wxWidgets/pull/26196/c3906033721@github.com>

Václav Slavík

unread,
Feb 16, 2026, 3:37:16 AMFeb 16
to wx-...@googlegroups.com, Subscribed
vslavik left a comment (wxWidgets/wxWidgets#26196)

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.Message ID: <wxWidgets/wxWidgets/pull/26196/c3907127256@github.com>

VZ

unread,
Feb 16, 2026, 11:16:25 AMFeb 16
to wx-...@googlegroups.com, Subscribed

Merged #26196 into master.


Reply to this email directly, view it on GitHub, or unsubscribe.

You are receiving this because you are subscribed to this thread.Message ID: <wxWidgets/wxWidgets/pull/26196/issue_event/22829897310@github.com>

taler21

unread,
Feb 17, 2026, 1:33:32 AMFeb 17
to wx-...@googlegroups.com, Subscribed
taler21 left a comment (wxWidgets/wxWidgets#26196)

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.Message ID: <wxWidgets/wxWidgets/pull/26196/c3912566697@github.com>

Maarten

unread,
Feb 17, 2026, 5:23:49 AMFeb 17
to wx-...@googlegroups.com, Subscribed
MaartenBent left a comment (wxWidgets/wxWidgets#26196)

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.Message ID: <wxWidgets/wxWidgets/pull/26196/c3913702194@github.com>

VZ

unread,
Feb 18, 2026, 10:11:37 AMFeb 18
to wx-...@googlegroups.com, Subscribed
vadz left a comment (wxWidgets/wxWidgets#26196)

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.Message ID: <wxWidgets/wxWidgets/pull/26196/c3921375677@github.com>

Reply all
Reply to author
Forward
0 new messages