Fix GetEncoding() after global fallback encoding is changed

Save global fallback encoding when switching to it, so GetEncoding() can still return the correct value if global fallback encoding is changed later. Also do not switch to wxFONTENCODING_MAX when it is set as global fallback encoding.
This commit is contained in:
Pavel Tyunin 2020-10-05 18:10:27 +03:00
parent 307a0916fd
commit d2e7b5bdd1
No known key found for this signature in database
GPG Key ID: EDFD0FC013D891EC

View File

@ -320,11 +320,11 @@ wxConvAuto::ToWChar(wchar_t *dst, size_t dstLen,
// if the conversion failed but we didn't really detect anything and
// simply tried UTF-8 by default, retry it using the fall-back
if ( m_encDefault == wxFONTENCODING_DEFAULT )
self->m_encDefault = GetFallbackEncoding();
if ( m_encDefault != wxFONTENCODING_MAX )
{
self->m_conv = new wxCSConv(m_encDefault == wxFONTENCODING_DEFAULT
? GetFallbackEncoding()
: m_encDefault);
self->m_conv = new wxCSConv(m_encDefault);
self->m_ownsConv = true;
rc = m_conv->ToWChar(dst, dstLen, src, srcLen);
@ -372,10 +372,8 @@ wxFontEncoding wxConvAuto::GetEncoding() const
return wxFONTENCODING_MAX;
else if ( !m_ownsConv )
return wxFONTENCODING_UTF8;
else if ( m_encDefault != wxFONTENCODING_DEFAULT )
return m_encDefault;
else
return GetFallbackEncoding();
return m_encDefault;
}
wxFAIL_MSG( "unknown BOM type" );