summaryrefslogtreecommitdiffstats
path: root/tests/auto/corelib/io/qfile
diff options
context:
space:
mode:
authorAhmad Samir <a.samirh78@gmail.com>2024-02-10 03:10:44 +0200
committerAhmad Samir <a.samirh78@gmail.com>2024-03-21 19:05:02 +0200
commit3c50ad828861bee82e53469deab28b4e286cbeda (patch)
tree36ab6a8c7f88fc7c729bdc1b958c81970b63e95c /tests/auto/corelib/io/qfile
parent0737fca6b2f4b29b7e4eda221147187cf72f96f3 (diff)
QFileSystemEngine: make factory functions return unique_ptr<QABFE>
This makes the ownership of the returned pointer clearer. It also matches reality, some call sites were already storing the pointer in a unique_ptr. Also shorten the function name to "createLegacyEngine", you have to read its docs anyway to figure out what it does. Drive-by changes: less magic numbers; use sliced(); return nullptr instead of `0`. Change-Id: I637759b4160b28b15adf5f6548de336887338dab Reviewed-by: Qt CI Bot <qt_ci_bot@qt-project.org> Reviewed-by: Assam Boudjelthia <assam.boudjelthia@qt.io>
Diffstat (limited to 'tests/auto/corelib/io/qfile')
-rw-r--r--tests/auto/corelib/io/qfile/tst_qfile.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/tests/auto/corelib/io/qfile/tst_qfile.cpp b/tests/auto/corelib/io/qfile/tst_qfile.cpp
index 9cf267be1f..65869ba5ab 100644
--- a/tests/auto/corelib/io/qfile/tst_qfile.cpp
+++ b/tests/auto/corelib/io/qfile/tst_qfile.cpp
@@ -2321,18 +2321,18 @@ private:
class MyHandler : public QAbstractFileEngineHandler
{
public:
- inline QAbstractFileEngine *create(const QString &) const override
+ std::unique_ptr<QAbstractFileEngine> create(const QString &) const override
{
- return new MyEngine(1);
+ return std::make_unique<MyEngine>(1);
}
};
class MyHandler2 : public QAbstractFileEngineHandler
{
public:
- inline QAbstractFileEngine *create(const QString &) const override
+ std::unique_ptr<QAbstractFileEngine> create(const QString &) const override
{
- return new MyEngine(2);
+ return std::make_unique<MyEngine>(2);
}
};
#endif
@@ -2361,7 +2361,7 @@ void tst_QFile::fileEngineHandler()
class MyRecursiveHandler : public QAbstractFileEngineHandler
{
public:
- inline QAbstractFileEngine *create(const QString &fileName) const override
+ std::unique_ptr<QAbstractFileEngine> create(const QString &fileName) const override
{
if (fileName.startsWith(":!")) {
QDir dir;
@@ -2372,9 +2372,9 @@ public:
const QString realFile = m_dataDir->filePath(fileName.mid(2));
#endif
if (dir.exists(realFile))
- return new QFSFileEngine(realFile);
+ return std::make_unique<QFSFileEngine>(realFile);
}
- return 0;
+ return nullptr;
}
#ifdef BUILTIN_TESTDATA