NOISSUE do not keep downloads in memory, add (some) missing virtual dtors

This commit is contained in:
Petr Mrázek 2018-06-28 21:34:56 +02:00
parent 19bb50b872
commit b5f636b3d5
24 changed files with 36 additions and 84 deletions

View File

@ -368,6 +368,8 @@ public:
connect(&m_backoffTimer, &QTimer::timeout, this, &FolderInstanceStaging::childSucceded); connect(&m_backoffTimer, &QTimer::timeout, this, &FolderInstanceStaging::childSucceded);
} }
virtual ~FolderInstanceStaging() {};
protected: protected:
virtual void executeTask() override virtual void executeTask() override
{ {

View File

@ -28,6 +28,7 @@ class JavaCheckerJob : public Task
Q_OBJECT Q_OBJECT
public: public:
explicit JavaCheckerJob(QString job_name) : Task(), m_job_name(job_name) {}; explicit JavaCheckerJob(QString job_name) : Task(), m_job_name(job_name) {};
virtual ~JavaCheckerJob() {};
bool addJavaCheckerAction(JavaCheckerPtr base) bool addJavaCheckerAction(JavaCheckerPtr base)
{ {

View File

@ -68,7 +68,7 @@ class JavaListLoadTask : public Task
public: public:
explicit JavaListLoadTask(JavaInstallList *vlist); explicit JavaListLoadTask(JavaInstallList *vlist);
~JavaListLoadTask(); virtual ~JavaListLoadTask();
void executeTask() override; void executeTask() override;
public slots: public slots:

View File

@ -23,6 +23,8 @@ class PostLaunchCommand: public LaunchStep
Q_OBJECT Q_OBJECT
public: public:
explicit PostLaunchCommand(LaunchTask *parent); explicit PostLaunchCommand(LaunchTask *parent);
virtual ~PostLaunchCommand() {};
virtual void executeTask(); virtual void executeTask();
virtual bool abort(); virtual bool abort();
virtual bool canAbort() const virtual bool canAbort() const

View File

@ -23,6 +23,8 @@ class PreLaunchCommand: public LaunchStep
Q_OBJECT Q_OBJECT
public: public:
explicit PreLaunchCommand(LaunchTask *parent); explicit PreLaunchCommand(LaunchTask *parent);
virtual ~PreLaunchCommand() {};
virtual void executeTask(); virtual void executeTask();
virtual bool abort(); virtual bool abort();
virtual bool canAbort() const virtual bool canAbort() const

View File

@ -32,6 +32,7 @@ class MinecraftLoadAndCheck : public Task
Q_OBJECT Q_OBJECT
public: public:
explicit MinecraftLoadAndCheck(MinecraftInstance *inst, QObject *parent = 0); explicit MinecraftLoadAndCheck(MinecraftInstance *inst, QObject *parent = 0);
virtual ~MinecraftLoadAndCheck() {};
void executeTask() override; void executeTask() override;
private slots: private slots:

View File

@ -32,6 +32,8 @@ class OneSixUpdate : public Task
Q_OBJECT Q_OBJECT
public: public:
explicit OneSixUpdate(MinecraftInstance *inst, QObject *parent = 0); explicit OneSixUpdate(MinecraftInstance *inst, QObject *parent = 0);
virtual ~OneSixUpdate() {};
void executeTask() override; void executeTask() override;
bool canAbort() const override; bool canAbort() const override;

View File

@ -21,7 +21,6 @@ public:
// Note this class takes ownership of the file. // Note this class takes ownership of the file.
SkinUpload(QObject *parent, AuthSessionPtr session, QByteArray skin, Model model = STEVE); SkinUpload(QObject *parent, AuthSessionPtr session, QByteArray skin, Model model = STEVE);
virtual ~SkinUpload() {} virtual ~SkinUpload() {}
private: private:

View File

@ -34,6 +34,7 @@ class YggdrasilTask : public Task
Q_OBJECT Q_OBJECT
public: public:
explicit YggdrasilTask(MojangAccount * account, QObject *parent = 0); explicit YggdrasilTask(MojangAccount * account, QObject *parent = 0);
virtual ~YggdrasilTask() {};
/** /**
* assign a session to this task. the session will be filled with required infomration * assign a session to this task. the session will be filled with required infomration

View File

@ -23,6 +23,8 @@ class ClaimAccount: public LaunchStep
Q_OBJECT Q_OBJECT
public: public:
explicit ClaimAccount(LaunchTask *parent, AuthSessionPtr session); explicit ClaimAccount(LaunchTask *parent, AuthSessionPtr session);
virtual ~ClaimAccount() {};
void executeTask() override; void executeTask() override;
void finalize() override; void finalize() override;
bool canAbort() const override bool canAbort() const override

View File

@ -25,6 +25,8 @@ class CreateServerResourcePacksFolder: public LaunchStep
Q_OBJECT Q_OBJECT
public: public:
explicit CreateServerResourcePacksFolder(LaunchTask *parent); explicit CreateServerResourcePacksFolder(LaunchTask *parent);
virtual ~CreateServerResourcePacksFolder() {};
virtual void executeTask(); virtual void executeTask();
virtual bool canAbort() const virtual bool canAbort() const
{ {

View File

@ -24,6 +24,8 @@ class DirectJavaLaunch: public LaunchStep
Q_OBJECT Q_OBJECT
public: public:
explicit DirectJavaLaunch(LaunchTask *parent); explicit DirectJavaLaunch(LaunchTask *parent);
virtual ~DirectJavaLaunch() {};
virtual void executeTask(); virtual void executeTask();
virtual bool abort(); virtual bool abort();
virtual void proceed(); virtual void proceed();

View File

@ -24,6 +24,8 @@ class LauncherPartLaunch: public LaunchStep
Q_OBJECT Q_OBJECT
public: public:
explicit LauncherPartLaunch(LaunchTask *parent); explicit LauncherPartLaunch(LaunchTask *parent);
virtual ~LauncherPartLaunch() {};
virtual void executeTask(); virtual void executeTask();
virtual bool abort(); virtual bool abort();
virtual void proceed(); virtual void proceed();

View File

@ -96,86 +96,6 @@ shared_qobject_ptr<Task> LegacyInstance::createUpdateTask(Net::Mode)
return nullptr; return nullptr;
} }
/*
class LegacyJarModTask : public Task
{
//Q_OBJECT
public:
explicit LegacyJarModTask(std::shared_ptr<LegacyInstance> inst) : Task(nullptr), m_inst(inst)
{
}
virtual void executeTask()
{
if (!m_inst->shouldRebuild())
{
emitSucceeded();
return;
}
// Get the mod list
auto modList = m_inst->getJarMods();
QFileInfo runnableJar(m_inst->runnableJar());
QFileInfo baseJar(m_inst->baseJar());
bool base_is_custom = m_inst->shouldUseCustomBaseJar();
// Nothing to do if there are no jar mods to install, no backup and just the mc jar
if (base_is_custom)
{
// yes, this can happen if the instance only has the runnable jar and not the base jar
// it *could* be assumed that such an instance is vanilla, but that wouldn't be safe
// because that's not something mmc4 guarantees
if (runnableJar.isFile() && !baseJar.exists() && modList.empty())
{
m_inst->setShouldRebuild(false);
emitSucceeded();
return;
}
setStatus(tr("Installing mods: Backing up minecraft.jar ..."));
if (!baseJar.exists() && !QFile::copy(runnableJar.filePath(), baseJar.filePath()))
{
emitFailed("It seems both the active and base jar are gone. A fresh base jar will "
"be used on next run.");
m_inst->setShouldRebuild(true);
m_inst->setShouldUpdate(true);
m_inst->setShouldUseCustomBaseJar(false);
return;
}
}
if (!baseJar.exists())
{
emitFailed("The base jar " + baseJar.filePath() + " does not exist");
return;
}
if (runnableJar.exists() && !QFile::remove(runnableJar.filePath()))
{
emitFailed("Failed to delete old minecraft.jar");
return;
}
setStatus(tr("Installing mods: Opening minecraft.jar ..."));
QString outputJarPath = runnableJar.filePath();
QString inputJarPath = baseJar.filePath();
if(!MMCZip::createModdedJar(inputJarPath, outputJarPath, modList))
{
emitFailed(tr("Failed to create the custom Minecraft jar file."));
return;
}
m_inst->setShouldRebuild(false);
// inst->UpdateVersion(true);
emitSucceeded();
return;
}
std::shared_ptr<LegacyInstance> m_inst;
};
*/
std::shared_ptr<LegacyModList> LegacyInstance::jarModList() const std::shared_ptr<LegacyModList> LegacyInstance::jarModList() const
{ {
if (!jar_mod_list) if (!jar_mod_list)

View File

@ -9,6 +9,11 @@ AssetUpdateTask::AssetUpdateTask(MinecraftInstance * inst)
{ {
m_inst = inst; m_inst = inst;
} }
AssetUpdateTask::~AssetUpdateTask()
{
}
void AssetUpdateTask::executeTask() void AssetUpdateTask::executeTask()
{ {
setStatus(tr("Updating assets index...")); setStatus(tr("Updating assets index..."));

View File

@ -8,6 +8,8 @@ class AssetUpdateTask : public Task
Q_OBJECT Q_OBJECT
public: public:
AssetUpdateTask(MinecraftInstance * inst); AssetUpdateTask(MinecraftInstance * inst);
virtual ~AssetUpdateTask();
void executeTask() override; void executeTask() override;
bool canAbort() const override; bool canAbort() const override;

View File

@ -10,6 +10,7 @@ class FMLLibrariesTask : public Task
Q_OBJECT Q_OBJECT
public: public:
FMLLibrariesTask(MinecraftInstance * inst); FMLLibrariesTask(MinecraftInstance * inst);
virtual ~FMLLibrariesTask() {};
void executeTask() override; void executeTask() override;

View File

@ -8,6 +8,8 @@ class FoldersTask : public Task
Q_OBJECT Q_OBJECT
public: public:
FoldersTask(MinecraftInstance * inst); FoldersTask(MinecraftInstance * inst);
virtual ~FoldersTask() {};
void executeTask() override; void executeTask() override;
private: private:
MinecraftInstance *m_inst; MinecraftInstance *m_inst;

View File

@ -8,6 +8,7 @@ class LibrariesTask : public Task
Q_OBJECT Q_OBJECT
public: public:
LibrariesTask(MinecraftInstance * inst); LibrariesTask(MinecraftInstance * inst);
virtual ~LibrariesTask() {};
void executeTask() override; void executeTask() override;

View File

@ -13,6 +13,8 @@ class MULTIMC_LOGIC_EXPORT FileResolvingTask : public Task
Q_OBJECT Q_OBJECT
public: public:
explicit FileResolvingTask(Flame::Manifest &toProcess); explicit FileResolvingTask(Flame::Manifest &toProcess);
virtual ~FileResolvingTask() {};
const Flame::Manifest &getResults() const const Flame::Manifest &getResults() const
{ {
return m_toProcess; return m_toProcess;

View File

@ -24,7 +24,6 @@ public: /* methods */
bool write(QByteArray & data) override bool write(QByteArray & data) override
{ {
m_checksum.addData(data); m_checksum.addData(data);
this->data.append(data);
return true; return true;
} }
bool abort() override bool abort() override
@ -50,7 +49,6 @@ public: /* methods */
} }
private: /* data */ private: /* data */
QByteArray data;
QCryptographicHash m_checksum; QCryptographicHash m_checksum;
QByteArray m_expected; QByteArray m_expected;
}; };

View File

@ -12,6 +12,7 @@ class MULTIMC_LOGIC_EXPORT PasteUpload : public Task
public: public:
PasteUpload(QWidget *window, QString text, QString key = "public"); PasteUpload(QWidget *window, QString text, QString key = "public");
virtual ~PasteUpload(); virtual ~PasteUpload();
QString pasteLink() QString pasteLink()
{ {
return m_pasteLink; return m_pasteLink;

View File

@ -12,6 +12,7 @@ class MULTIMC_LOGIC_EXPORT SequentialTask : public Task
Q_OBJECT Q_OBJECT
public: public:
explicit SequentialTask(QObject *parent = 0); explicit SequentialTask(QObject *parent = 0);
virtual ~SequentialTask() {};
void addTask(std::shared_ptr<Task> task); void addTask(std::shared_ptr<Task> task);

View File

@ -38,6 +38,7 @@ public:
* target is a template - XXXXXX at the end will be replaced with a random generated string, ensuring uniqueness * target is a template - XXXXXX at the end will be replaced with a random generated string, ensuring uniqueness
*/ */
explicit DownloadTask(Status status, QString target, QObject* parent = 0); explicit DownloadTask(Status status, QString target, QObject* parent = 0);
virtual ~DownloadTask() {};
/// Get the directory that will contain the update files. /// Get the directory that will contain the update files.
QString updateFilesDir(); QString updateFilesDir();