diff options
author | Ivan Komissarov <abbapoh@gmail.com> | 2021-05-13 01:24:34 +0200 |
---|---|---|
committer | Ivan Komissarov <ABBAPOH@gmail.com> | 2021-05-13 16:27:13 +0000 |
commit | 05d16754fe403af343e256c032d83970420b058b (patch) | |
tree | 95ce9f4c101c758fd98d4f331b180201ac3066a1 /src/plugins/scanner | |
parent | 1cd7ba74dc253a111ab3ff115547842c90421b94 (diff) | |
download | qbs-05d16754fe403af343e256c032d83970420b058b.tar.gz |
Use smart pointers in Qt scanner
Change-Id: I5ed9a9d97eeabff70b5a67f3e7fcfbe49fb13675
Reviewed-by: Denis Shienkov <denis.shienkov@gmail.com>
Diffstat (limited to 'src/plugins/scanner')
-rw-r--r-- | src/plugins/scanner/qt/qtscanner.cpp | 13 |
1 files changed, 6 insertions, 7 deletions
diff --git a/src/plugins/scanner/qt/qtscanner.cpp b/src/plugins/scanner/qt/qtscanner.cpp index 310de33fc..81f0d602b 100644 --- a/src/plugins/scanner/qt/qtscanner.cpp +++ b/src/plugins/scanner/qt/qtscanner.cpp @@ -71,11 +71,11 @@ struct OpaqQrc int fd = 0; int mapl = 0; #else - QFile *file = nullptr; + std::unique_ptr<QFile> file; #endif char *map = nullptr; - QXmlStreamReader *xml = nullptr; + std::unique_ptr<QXmlStreamReader> xml; QByteArray current; OpaqQrc() = default; @@ -86,10 +86,7 @@ struct OpaqQrc munmap (map, mapl); if (fd) close (fd); -#else - delete file; #endif - delete xml; } }; @@ -118,7 +115,8 @@ static void *openScannerQrc(const unsigned short *filePath, const char *fileTags if (map == nullptr) return nullptr; #else - opaque->file = new QFile(QString::fromUtf16(reinterpret_cast<const char16_t *>(filePath))); + opaque->file = std::make_unique<QFile>( + QString::fromUtf16(reinterpret_cast<const char16_t *>(filePath))); if (!opaque->file->open(QFile::ReadOnly)) return nullptr; @@ -129,7 +127,8 @@ static void *openScannerQrc(const unsigned short *filePath, const char *fileTags #endif opaque->map = reinterpret_cast<char *>(map); - opaque->xml = new QXmlStreamReader(QByteArray::fromRawData(opaque->map, fileSize)); + opaque->xml = std::make_unique<QXmlStreamReader>( + QByteArray::fromRawData(opaque->map, fileSize)); return static_cast<void *>(opaque.release()); } |