From 034d8898f8166423db085da529787e56204c8e15 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?M=C3=A5rten=20Nordheim?= Date: Fri, 4 Mar 2022 12:28:49 +0100 Subject: Fix deprecated uses of QScopedPointer By changing it to unique_ptr. Pick-to: 6.2 6.3 Change-Id: I91abb69445b537d4c95983ae735341882352b29d Reviewed-by: Marc Mutz Reviewed-by: Thiago Macieira --- src/testlib/qtestcase.cpp | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) (limited to 'src/testlib/qtestcase.cpp') 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 #include #include +#include #include #include @@ -1357,9 +1358,9 @@ char *toHexRepresentation(const char *ba, int length) char *toPrettyCString(const char *p, int length) { bool trimmed = false; - QScopedArrayPointer buffer(new char[256]); + auto buffer = std::make_unique(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 buffer(new char[256]); + auto buffer = std::make_unique(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 -- cgit v1.2.3