On Sun, Mar 21, 2021 at 12:33:12PM +0100, Juergen Spitzmueller wrote:
> commit 52dff70641788cdd99ca40cf30550861555191c3
> Author: Juergen Spitzmueller <sp...@lyx.org>
> Date:   Sun Mar 21 12:38:47 2021 +0100
> 
>     Fix Qt6 deprecation warning (QString::fromUcs4(uint))

Note that this is wrong on systems where the size of wchar_t is 2 bytes.
If wchar_t is 4 bytes, the argument of those functions is interpreted as
UCS-4, but if wchar_t is 2 bytes it is interpreted as UTF-16.

I think you should use QString::fromStdU32String or similar.

> ---
>  src/support/qstring_helpers.cpp |    8 ++++++++
>  1 files changed, 8 insertions(+), 0 deletions(-)
> 
> diff --git a/src/support/qstring_helpers.cpp b/src/support/qstring_helpers.cpp
> index d34e455..103f4a9 100644
> --- a/src/support/qstring_helpers.cpp
> +++ b/src/support/qstring_helpers.cpp
> @@ -47,13 +47,21 @@ QString toqstr(docstring const & ucs4)
>       // need to be superfast.
>       if (ucs4.empty())
>               return QString();
> +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
> +     return QString::fromStdWString(ucs4);
> +#else
>       return QString::fromUcs4((uint const *)ucs4.data(), ucs4.length());
> +#endif
>  }
>  
>  QString toqstr(char_type ucs4)
>  {
> +#if (QT_VERSION >= QT_VERSION_CHECK(6, 0, 0))
> +     return QString::fromWCharArray(&ucs4, 1);
> +#else
>       union { char_type c; uint i; } u = { ucs4 };
>       return QString::fromUcs4(&u.i, 1);
> +#endif
>  }
>  
>  docstring qstring_to_ucs4(QString const & qstr)
> -- 
> lyx-cvs mailing list
> lyx-...@lists.lyx.org
> http://lists.lyx.org/mailman/listinfo/lyx-cvs

-- 
Enrico
-- 
lyx-devel mailing list
lyx-devel@lists.lyx.org
http://lists.lyx.org/mailman/listinfo/lyx-devel

Reply via email to