use shared pointer

Signed-off-by: Trial97 <alexandru.tripon97@gmail.com>

use shared pointer
This commit is contained in:
Trial97 2023-07-16 21:12:53 +03:00
parent cadb7142f0
commit 79222a56e3
No known key found for this signature in database
GPG Key ID: 55EF5DA53DB36318
2 changed files with 8 additions and 18 deletions

View File

@ -451,7 +451,7 @@ void ExportToZipTask::executeTask()
absolute = file.canonicalFilePath();
}
if (!JlCompress::compressFile(m_output, absolute, m_destinationPrefix + relative)) {
if (!JlCompress::compressFile(m_output.get(), absolute, m_destinationPrefix + relative)) {
emitFailed(tr("Could not read and compress %1").arg(relative));
return;
}

View File

@ -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