diff options
author | Lars Knoll <lars.knoll@qt.io> | 2020-07-06 09:36:32 +0200 |
---|---|---|
committer | Lars Knoll <lars.knoll@qt.io> | 2020-07-06 11:31:43 +0200 |
commit | a5025efccfa877426dcdf31d91cacb1a6c52b276 (patch) | |
tree | 24de4172a1ddcb92258fbe64b89d68e061f2a145 /src/gui/kernel/qclipboard.cpp | |
parent | cd67fe582142b308f98eab30d057eceaee8d6d88 (diff) |
Fix a crash in QClipBoard when copying utf16 data
Properly use the new QStringConverter API and not an internal
qFromUtfEncoded method that was buggy after the changes.
Take the oppportunity to clean up and remove qFromUtfEncoded, as
QClipboard was its only user.
Fixes: QTBUG-85417
Change-Id: I8540d12056bf3f448c1f628ce0bd0ad462a6447d
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@qt.io>
Diffstat (limited to 'src/gui/kernel/qclipboard.cpp')
-rw-r--r-- | src/gui/kernel/qclipboard.cpp | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/src/gui/kernel/qclipboard.cpp b/src/gui/kernel/qclipboard.cpp index eb6c2af6d1..d51c356970 100644 --- a/src/gui/kernel/qclipboard.cpp +++ b/src/gui/kernel/qclipboard.cpp @@ -286,7 +286,10 @@ QString QClipboard::text(QString &subtype, Mode mode) const } const QByteArray rawData = data->data(QLatin1String("text/") + subtype); - return qFromUtfEncoded(rawData); + auto encoding = QStringConverter::encodingForData(rawData.constData(), rawData.size()); + if (!encoding) + encoding = QStringConverter::Utf8; + return QStringDecoder(*encoding).decode(rawData); } /*! |