NOISSUE replace std::shared_ptr with shared_qobject_ptr for all download tasks

This commit is contained in:
Petr Mrázek 2017-05-03 21:09:36 +02:00
parent 907aa36704
commit 0efa714ba5
10 changed files with 18 additions and 16 deletions

View File

@ -51,7 +51,7 @@ void Library::getApplicableFiles(OpSys system, QStringList& jar, QStringList& na
}
}
QList< std::shared_ptr< NetAction > > Library::getDownloads(OpSys system, class HttpMetaCache* cache,
QList<NetActionPtr> Library::getDownloads(OpSys system, class HttpMetaCache* cache,
QStringList& failedFiles, const QString & overridePath) const
{
QList<NetActionPtr> out;

View File

@ -19,8 +19,9 @@
#include "net/HttpMetaCache.h"
#include <QFile>
#include <QTemporaryFile>
#include "QObjectPtr.h"
typedef std::shared_ptr<class ForgeXzDownload> ForgeXzDownloadPtr;
typedef shared_qobject_ptr<class ForgeXzDownload> ForgeXzDownloadPtr;
class ForgeXzDownload : public NetAction
{

View File

@ -41,7 +41,7 @@ OneSixUpdate::OneSixUpdate(OneSixInstance *inst, QObject *parent) : Task(parent)
{
// create folders
{
m_tasks.append(std::make_shared<FoldersTask>(m_inst));
m_tasks.append(new FoldersTask(m_inst));
}
// add metadata update tasks, if necessary
@ -66,7 +66,7 @@ OneSixUpdate::OneSixUpdate(OneSixInstance *inst, QObject *parent) : Task(parent)
if(task)
{
qDebug() << "Loading remote meta patch" << id;
m_tasks.append(task.unwrap());
m_tasks.append(task);
}
}
else
@ -78,17 +78,17 @@ OneSixUpdate::OneSixUpdate(OneSixInstance *inst, QObject *parent) : Task(parent)
// libraries download
{
m_tasks.append(std::make_shared<LibrariesTask>(m_inst));
m_tasks.append(new LibrariesTask(m_inst));
}
// FML libraries download and copy into the instance
{
m_tasks.append(std::make_shared<FMLLibrariesTask>(m_inst));
m_tasks.append(new FMLLibrariesTask(m_inst));
}
// assets update
{
m_tasks.append(std::make_shared<AssetUpdateTask>(m_inst));
m_tasks.append(new AssetUpdateTask(m_inst));
}
}

View File

@ -46,7 +46,7 @@ private:
private:
OneSixInstance *m_inst = nullptr;
QList<std::shared_ptr<Task>> m_tasks;
QList<shared_qobject_ptr<Task>> m_tasks;
QString m_preFailure;
int m_currentTask = -1;
bool m_abort = false;

View File

@ -40,7 +40,7 @@ Download::Ptr Download::makeCached(QUrl url, MetaEntryPtr entry, Options options
auto cachedNode = new MetaCacheSink(entry, md5Node);
dl->m_sink.reset(cachedNode);
dl->m_target_path = entry->getFullPath();
return std::shared_ptr<Download>(dl);
return dl;
}
Download::Ptr Download::makeByteArray(QUrl url, QByteArray *output, Options options)
@ -49,7 +49,7 @@ Download::Ptr Download::makeByteArray(QUrl url, QByteArray *output, Options opti
dl->m_url = url;
dl->m_options = options;
dl->m_sink.reset(new ByteArraySink(output));
return std::shared_ptr<Download>(dl);
return dl;
}
Download::Ptr Download::makeFile(QUrl url, QString path, Options options)
@ -58,7 +58,7 @@ Download::Ptr Download::makeFile(QUrl url, QString path, Options options)
dl->m_url = url;
dl->m_options = options;
dl->m_sink.reset(new FileSink(path));
return std::shared_ptr<Download>(dl);
return dl;
}
void Download::addValidator(Validator * v)

View File

@ -27,7 +27,7 @@ class MULTIMC_LOGIC_EXPORT Download : public NetAction
Q_OBJECT
public: /* types */
typedef std::shared_ptr<class Download> Ptr;
typedef shared_qobject_ptr<class Download> Ptr;
enum class Option
{
NoOptions = 0,

View File

@ -25,7 +25,7 @@
#include "multimc_logic_export.h"
typedef std::shared_ptr<class NetAction> NetActionPtr;
typedef shared_qobject_ptr<class NetAction> NetActionPtr;
class MULTIMC_LOGIC_EXPORT NetAction : public Task
{
Q_OBJECT

View File

@ -4,7 +4,7 @@
#include "multimc_logic_export.h"
typedef std::shared_ptr<class ImgurAlbumCreation> ImgurAlbumCreationPtr;
typedef shared_qobject_ptr<class ImgurAlbumCreation> ImgurAlbumCreationPtr;
class MULTIMC_LOGIC_EXPORT ImgurAlbumCreation : public NetAction
{
public:

View File

@ -1,10 +1,11 @@
#pragma once
#include "net/NetAction.h"
#include "Screenshot.h"
#include "QObjectPtr.h"
#include "multimc_logic_export.h"
typedef std::shared_ptr<class ImgurUpload> ImgurUploadPtr;
typedef shared_qobject_ptr<class ImgurUpload> ImgurUploadPtr;
class MULTIMC_LOGIC_EXPORT ImgurUpload : public NetAction
{
public:

View File

@ -30,7 +30,7 @@ struct TranslationsModel::Private
std::unique_ptr<QTranslator> m_qt_translator;
std::unique_ptr<QTranslator> m_app_translator;
std::shared_ptr<Net::Download> m_index_task;
Net::Download::Ptr m_index_task;
QString m_downloadingTranslation;
NetJobPtr m_dl_job;
NetJobPtr m_index_job;