diff options
author | Mårten Nordheim <marten.nordheim@qt.io> | 2022-03-04 12:28:49 +0100 |
---|---|---|
committer | Mårten Nordheim <marten.nordheim@qt.io> | 2022-03-08 15:44:17 +0100 |
commit | 034d8898f8166423db085da529787e56204c8e15 (patch) | |
tree | f58e930c7880d1cd79cd39745ed366d27dcd9e55 /src/testlib/qtestcase.cpp | |
parent | 87725ee75981ec9ab25456c41acc74681c85ae2e (diff) |
Fix deprecated uses of QScopedPointer
By changing it to unique_ptr.
Pick-to: 6.2 6.3
Change-Id: I91abb69445b537d4c95983ae735341882352b29d
Reviewed-by: Marc Mutz <marc.mutz@qt.io>
Reviewed-by: Thiago Macieira <thiago.macieira@intel.com>
Diffstat (limited to 'src/testlib/qtestcase.cpp')
-rw-r--r-- | src/testlib/qtestcase.cpp | 17 |
1 files changed, 9 insertions, 8 deletions
diff --git a/src/testlib/qtestcase.cpp b/src/testlib/qtestcase.cpp index 8bdf7f6ae9..5176c03931 100644 --- a/src/testlib/qtestcase.cpp +++ b/src/testlib/qtestcase.cpp @@ -87,6 +87,7 @@ #include <algorithm> #include <mutex> #include <chrono> +#include <memory> #include <stdarg.h> #include <stdio.h> @@ -1357,9 +1358,9 @@ char *toHexRepresentation(const char *ba, int length) char *toPrettyCString(const char *p, int length) { bool trimmed = false; - QScopedArrayPointer<char> buffer(new char[256]); + auto buffer = std::make_unique<char[]>(256); const char *end = p + length; - char *dst = buffer.data(); + char *dst = buffer.get(); bool lastWasHexEscape = false; *dst++ = '"'; @@ -1369,7 +1370,7 @@ char *toPrettyCString(const char *p, int length) // 2 bytes: a simple escape sequence (\n) // 3 bytes: "" and a character // 4 bytes: an hex escape sequence (\xHH) - if (dst - buffer.data() > 246) { + if (dst - buffer.get() > 246) { // plus the quote, the three dots and NUL, it's 255 in the worst case trimmed = true; break; @@ -1430,7 +1431,7 @@ char *toPrettyCString(const char *p, int length) *dst++ = '.'; } *dst++ = '\0'; - return buffer.take(); + return buffer.release(); } #if QT_VERSION < QT_VERSION_CHECK(6, 0, 0) @@ -1456,13 +1457,13 @@ char *toPrettyUnicode(QStringView string) auto length = string.size(); // keep it simple for the vast majority of cases bool trimmed = false; - QScopedArrayPointer<char> buffer(new char[256]); + auto buffer = std::make_unique<char[]>(256); const auto end = p + length; - char *dst = buffer.data(); + char *dst = buffer.get(); *dst++ = '"'; for ( ; p != end; ++p) { - if (dst - buffer.data() > 245) { + if (dst - buffer.get() > 245) { // plus the quote, the three dots and NUL, it's 250, 251 or 255 trimmed = true; break; @@ -1512,7 +1513,7 @@ char *toPrettyUnicode(QStringView string) *dst++ = '.'; } *dst++ = '\0'; - return buffer.take(); + return buffer.release(); } void TestMethods::invokeTests(QObject *testObject) const |