diff options
| author | Øystein Heskestad <oystein.heskestad@qt.io> | 2022-01-05 13:10:17 +0100 |
|---|---|---|
| committer | Øystein Heskestad <oystein.heskestad@qt.io> | 2022-01-07 14:31:38 +0100 |
| commit | 18671b0491e4806fdff95aac6c16a067890ef030 (patch) | |
| tree | 41fad02e0756f430993aadf377189c14b5f62889 /src/plugins/platforms/windows/qwindowsmime.cpp | |
| parent | a5b158ed6dd5e393eab78f4034a93ac1250850e3 (diff) | |
| download | qtbase-18671b0491e4806fdff95aac6c16a067890ef030.tar.gz | |
Replace QString::utf16() with data() in memcpy() and QByteArray ctor
QString::utf16() needlessly detaches fromRawData() to ensure a
terminating NUL. Use data() where we don't require said NUL, taking
care not to call the mutable data() overload, which would detach,
too.
Task-number: QTBUG-98763
Change-Id: I7075a8f18ab1f82ebbcf8cfab1643e8ab7f38d51
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Diffstat (limited to 'src/plugins/platforms/windows/qwindowsmime.cpp')
| -rw-r--r-- | src/plugins/platforms/windows/qwindowsmime.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/plugins/platforms/windows/qwindowsmime.cpp b/src/plugins/platforms/windows/qwindowsmime.cpp index 3321845411..9c669c8fbc 100644 --- a/src/plugins/platforms/windows/qwindowsmime.cpp +++ b/src/plugins/platforms/windows/qwindowsmime.cpp @@ -670,7 +670,7 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat auto *f = reinterpret_cast<wchar_t *>(files); for (int i=0; i<fileNames.size(); i++) { const auto l = size_t(fileNames.at(i).length()); - memcpy(f, fileNames.at(i).utf16(), l * sizeof(ushort)); + memcpy(f, fileNames.at(i).data(), l * sizeof(ushort)); f += l; *f++ = 0; } @@ -682,8 +682,8 @@ bool QWindowsMimeURI::convertFromMime(const FORMATETC &formatetc, const QMimeDat const auto urls = mimeData->urls(); QByteArray result; if (!urls.isEmpty()) { - QString url = urls.at(0).toString(); - result = QByteArray(reinterpret_cast<const char *>(url.utf16()), + const QString url = urls.at(0).toString(); + result = QByteArray(reinterpret_cast<const char *>(url.data()), url.length() * int(sizeof(ushort))); } result.append('\0'); |
