Merge branch 'avoid-impl-string-conv-logstatus'

Avoid implicit string conversions when using wxLog functions.

See #24271.
This commit is contained in:
Vadim Zeitlin 2024-02-03 21:52:27 +01:00
commit dba79a2d67
2 changed files with 8 additions and 3 deletions

View file

@ -921,12 +921,15 @@ public:
// indicates that we may have an extra first argument preceding the format
// string and that if we do have it, we should store it in m_info using the
// given key (while by default 0 value will be used)
wxLogger& MaybeStore(const wxString& key, wxUIntPtr value = 0)
wxLogger& MaybeStore(const char* key, wxUIntPtr value = 0)
{
wxASSERT_MSG( m_optKey.empty(), "can only have one optional value" );
m_optKey = key;
m_info.StoreValue(key, value);
// We only use keys defined in this file and we can be sure they
// contain ASCII characters only.
m_optKey = wxString::FromAscii(key);
m_info.StoreValue(m_optKey, value);
return *this;
}

View file

@ -411,4 +411,6 @@ TEST_CASE("wxNO_IMPLICIT_WXSTRING_ENCODING", "[string]")
// wxNO_IMPLICIT_WXSTRING_ENCODING must be set
s = "Hello, implicit encoding";
#endif
wxLogSysError(wxASCII_STR("Bogus error for testing"));
}