Skip to content

Commit

Permalink
tst_utf8: use QScopedPointer, not QSharedPointer
Browse files Browse the repository at this point in the history
There's no sharing, and the use of QSharedPointer(T*)
triggers my tree's static analyzer.

Easiest fix is to port to QScopedPointer, which is the
correct smart pointer to begin with.

Change-Id: I105c1a334c3d6712a475600c8394b0bebc420677
Reviewed-by: Lars Knoll <[email protected]>
Reviewed-by: Thiago Macieira <[email protected]>
  • Loading branch information
marc-kdab committed Aug 6, 2016
1 parent c0b6e16 commit e38064f
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions tests/auto/corelib/codecs/utf8/tst_utf8.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
#include <QtTest/QtTest>

#include <qtextcodec.h>
#include <qsharedpointer.h>
#include <QScopedPointer>

static const char utf8bom[] = "\xEF\xBB\xBF";

Expand Down Expand Up @@ -180,7 +180,7 @@ void tst_Utf8::charByChar()

{
// from utf16 to utf8 char by char:
QSharedPointer<QTextEncoder> encoder = QSharedPointer<QTextEncoder>(codec->makeEncoder());
const QScopedPointer<QTextEncoder> encoder(codec->makeEncoder());
QByteArray encoded;

for (int i = 0; i < utf16.length(); ++i) {
Expand All @@ -194,7 +194,7 @@ void tst_Utf8::charByChar()
}
{
// from utf8 to utf16 char by char:
QSharedPointer<QTextDecoder> decoder = QSharedPointer<QTextDecoder>(codec->makeDecoder());
const QScopedPointer<QTextDecoder> decoder(codec->makeDecoder());
QString decoded;

for (int i = 0; i < utf8.length(); ++i) {
Expand All @@ -219,7 +219,7 @@ void tst_Utf8::invalidUtf8()
QFETCH(QByteArray, utf8);
QFETCH_GLOBAL(bool, useLocale);

QSharedPointer<QTextDecoder> decoder = QSharedPointer<QTextDecoder>(codec->makeDecoder());
const QScopedPointer<QTextDecoder> decoder(codec->makeDecoder());
decoder->toUnicode(utf8);

// Only enforce correctness on our UTF-8 decoder
Expand Down Expand Up @@ -280,7 +280,7 @@ void tst_Utf8::nonCharacters()
QFETCH(QString, utf16);
QFETCH_GLOBAL(bool, useLocale);

QSharedPointer<QTextDecoder> decoder = QSharedPointer<QTextDecoder>(codec->makeDecoder());
const QScopedPointer<QTextDecoder> decoder(codec->makeDecoder());
decoder->toUnicode(utf8);

// Only enforce correctness on our UTF-8 decoder
Expand All @@ -289,7 +289,7 @@ void tst_Utf8::nonCharacters()
else if (decoder->hasFailure())
qWarning("System codec reports failure when it shouldn't. Should report bug upstream.");

QSharedPointer<QTextEncoder> encoder(codec->makeEncoder());
const QScopedPointer<QTextEncoder> encoder(codec->makeEncoder());
encoder->fromUnicode(utf16);
if (!useLocale)
QVERIFY(!encoder->hasFailure());
Expand Down

0 comments on commit e38064f

Please sign in to comment.