From bc838b4773ab3a93be5ff869a9357b72b9cf875a Mon Sep 17 00:00:00 2001 From: Pavel Tyunin Date: Mon, 28 Sep 2020 22:11:17 +0300 Subject: [PATCH] Do not delete and create the fallback conversion again when it fails --- src/common/convauto.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/common/convauto.cpp b/src/common/convauto.cpp index dca91eb59b..50c5a956c7 100644 --- a/src/common/convauto.cpp +++ b/src/common/convauto.cpp @@ -307,7 +307,7 @@ wxConvAuto::ToWChar(wchar_t *dst, size_t dstLen, // try to convert using the auto-detected encoding size_t rc = m_conv->ToWChar(dst, dstLen, src, srcLen); - if ( rc == wxCONV_FAILED && m_bomType == wxBOM_None ) + if ( rc == wxCONV_FAILED && m_bomType == wxBOM_None && !m_ownsConv ) { // we may need more bytes before we can decode the input, don't switch // to the fall-back conversion in this case as it would prevent us from @@ -320,9 +320,6 @@ wxConvAuto::ToWChar(wchar_t *dst, size_t dstLen, // simply tried UTF-8 by default, retry it using the fall-back if ( m_encDefault != wxFONTENCODING_MAX ) { - if ( m_ownsConv ) - delete m_conv; - self->m_conv = new wxCSConv(m_encDefault == wxFONTENCODING_DEFAULT ? GetFallbackEncoding() : m_encDefault);