diff options
author | Trial97 <alexandru.tripon97@gmail.com> | 2023-07-16 21:12:53 +0300 |
---|---|---|
committer | Trial97 <alexandru.tripon97@gmail.com> | 2023-07-16 21:14:39 +0300 |
commit | 79222a56e38a696168dddcc92a970242e0f34053 (patch) | |
tree | f981c5106478ad4270581145713d2cf68a4ebef5 /launcher/MMCZip.h | |
parent | cadb7142f0fe5eab16198ca8079d544456a977cc (diff) | |
download | PrismLauncher-79222a56e38a696168dddcc92a970242e0f34053.tar.gz PrismLauncher-79222a56e38a696168dddcc92a970242e0f34053.tar.bz2 PrismLauncher-79222a56e38a696168dddcc92a970242e0f34053.zip |
use shared pointer
Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>
use shared pointer
Diffstat (limited to 'launcher/MMCZip.h')
-rw-r--r-- | launcher/MMCZip.h | 24 |
1 files changed, 7 insertions, 17 deletions
diff --git a/launcher/MMCZip.h b/launcher/MMCZip.h index 728dd3c8..ded169cd 100644 --- a/launcher/MMCZip.h +++ b/launcher/MMCZip.h @@ -43,6 +43,7 @@ #include <QSet> #include <QString> #include <functional> +#include <memory> #include <optional> #include "minecraft/mod/Mod.h" #include "tasks/Task.h" @@ -145,39 +146,28 @@ bool collectFileListRecursively(const QString& rootDir, const QString& subDir, Q class ExportToZipTask : public Task { public: - ExportToZipTask(QuaZip* output, + ExportToZipTask(std::shared_ptr<QuaZip> output, QDir dir, QFileInfoList files, QString destinationPrefix = "", - bool followSymlinks = false, - bool cleanUp = false) - : m_output(output) - , m_dir(dir) - , m_files(files) - , m_destinationPrefix(destinationPrefix) - , m_followSymlinks(followSymlinks) - , m_cleanUp(cleanUp) + bool followSymlinks = false) + : m_output(output), m_dir(dir), m_files(files), m_destinationPrefix(destinationPrefix), m_followSymlinks(followSymlinks) { setAbortable(true); }; ExportToZipTask(QString outputPath, QString dir, QFileInfoList files, QString destinationPrefix = "", bool followSymlinks = false) - : ExportToZipTask(new QuaZip(outputPath), QDir(dir), files, destinationPrefix, followSymlinks, true){}; + : ExportToZipTask(std::make_shared<QuaZip>(outputPath), QDir(dir), files, destinationPrefix, followSymlinks){}; - virtual ~ExportToZipTask() - { - if (m_cleanUp) - delete m_output; - } + virtual ~ExportToZipTask() = default; protected: virtual void executeTask() override; private: - QuaZip* m_output; + std::shared_ptr<QuaZip> m_output; QDir m_dir; QFileInfoList m_files; QString m_destinationPrefix; bool m_followSymlinks; - bool m_cleanUp; }; } // namespace MMCZip |