GH-2591 less std::shared_ptr and more shared_qobject_ptr

This eliminates some weird crashes.
This commit is contained in:
Petr Mrázek 2019-04-07 23:59:04 +02:00
parent 414946cad9
commit 70ed30f9e6
25 changed files with 79 additions and 83 deletions

View File

@ -80,7 +80,7 @@ protected slots:
void fileChanged(const QString &path); void fileChanged(const QString &path);
void SettingChanged(const Setting & setting, QVariant value); void SettingChanged(const Setting & setting, QVariant value);
private: private:
std::shared_ptr<QFileSystemWatcher> m_watcher; shared_qobject_ptr<QFileSystemWatcher> m_watcher;
bool is_watching; bool is_watching;
QMap<QString, int> name_index; QMap<QString, int> name_index;
QVector<MMCIcon> icons; QVector<MMCIcon> icons;

View File

@ -175,11 +175,6 @@ QString BaseInstance::instanceRoot() const
return m_rootDir; return m_rootDir;
} }
InstancePtr BaseInstance::getSharedPtr()
{
return shared_from_this();
}
SettingsObjectPtr BaseInstance::settings() const SettingsObjectPtr BaseInstance::settings() const
{ {
return m_settings; return m_settings;
@ -253,7 +248,7 @@ QStringList BaseInstance::extraArguments() const
return Commandline::splitArgs(settings()->get("JvmArgs").toString()); return Commandline::splitArgs(settings()->get("JvmArgs").toString());
} }
std::shared_ptr<LaunchTask> BaseInstance::getLaunchTask() shared_qobject_ptr<LaunchTask> BaseInstance::getLaunchTask()
{ {
return m_launchProcess; return m_launchProcess;
} }

View File

@ -134,8 +134,6 @@ public:
/// Sets the last launched time to 'val' milliseconds since epoch /// Sets the last launched time to 'val' milliseconds since epoch
void setLastLaunch(qint64 val = QDateTime::currentMSecsSinceEpoch()); void setLastLaunch(qint64 val = QDateTime::currentMSecsSinceEpoch());
InstancePtr getSharedPtr();
/*! /*!
* \brief Gets this instance's settings object. * \brief Gets this instance's settings object.
* This settings object stores instance-specific settings. * This settings object stores instance-specific settings.
@ -147,10 +145,10 @@ public:
virtual shared_qobject_ptr<Task> createUpdateTask(Net::Mode mode) = 0; virtual shared_qobject_ptr<Task> createUpdateTask(Net::Mode mode) = 0;
/// returns a valid launcher (task container) /// returns a valid launcher (task container)
virtual std::shared_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account) = 0; virtual shared_qobject_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account) = 0;
/// returns the current launch task (if any) /// returns the current launch task (if any)
std::shared_ptr<LaunchTask> getLaunchTask(); shared_qobject_ptr<LaunchTask> getLaunchTask();
/*! /*!
* Create envrironment variables for running the instance * Create envrironment variables for running the instance
@ -241,7 +239,7 @@ signals:
*/ */
void propertiesChanged(BaseInstance *inst); void propertiesChanged(BaseInstance *inst);
void launchTaskChanged(std::shared_ptr<LaunchTask>); void launchTaskChanged(shared_qobject_ptr<LaunchTask>);
void runningStatusChanged(bool running); void runningStatusChanged(bool running);
@ -255,7 +253,7 @@ protected: /* data */
SettingsObjectPtr m_settings; SettingsObjectPtr m_settings;
// InstanceFlags m_flags; // InstanceFlags m_flags;
bool m_isRunning = false; bool m_isRunning = false;
std::shared_ptr<LaunchTask> m_launchProcess; shared_qobject_ptr<LaunchTask> m_launchProcess;
QDateTime m_timeStarted; QDateTime m_timeStarted;
private: /* data */ private: /* data */
@ -265,6 +263,6 @@ private: /* data */
bool m_hasBrokenVersion = false; bool m_hasBrokenVersion = false;
}; };
Q_DECLARE_METATYPE(std::shared_ptr<BaseInstance>) Q_DECLARE_METATYPE(shared_qobject_ptr<BaseInstance>)
//Q_DECLARE_METATYPE(BaseInstance::InstanceFlag) //Q_DECLARE_METATYPE(BaseInstance::InstanceFlag)
//Q_DECLARE_OPERATORS_FOR_FLAGS(BaseInstance::InstanceFlags) //Q_DECLARE_OPERATORS_FOR_FLAGS(BaseInstance::InstanceFlags)

View File

@ -1,5 +1,6 @@
#pragma once #pragma once
#include "BaseInstance.h" #include "BaseInstance.h"
#include "launch/LaunchTask.h"
class NullInstance: public BaseInstance class NullInstance: public BaseInstance
{ {
@ -11,46 +12,46 @@ public:
setVersionBroken(true); setVersionBroken(true);
} }
virtual ~NullInstance() {}; virtual ~NullInstance() {};
virtual void saveNow() override void saveNow() override
{ {
} }
virtual QString getStatusbarDescription() override QString getStatusbarDescription() override
{ {
return tr("Unknown instance type"); return tr("Unknown instance type");
}; };
virtual QSet< QString > traits() const override QSet< QString > traits() const override
{ {
return {}; return {};
}; };
virtual QString instanceConfigFolder() const override QString instanceConfigFolder() const override
{ {
return instanceRoot(); return instanceRoot();
}; };
virtual std::shared_ptr<LaunchTask> createLaunchTask(AuthSessionPtr) override shared_qobject_ptr<LaunchTask> createLaunchTask(AuthSessionPtr) override
{ {
return nullptr; return nullptr;
} }
virtual shared_qobject_ptr< Task > createUpdateTask(Net::Mode mode) override shared_qobject_ptr< Task > createUpdateTask(Net::Mode mode) override
{ {
return nullptr; return nullptr;
} }
virtual QProcessEnvironment createEnvironment() override QProcessEnvironment createEnvironment() override
{ {
return QProcessEnvironment(); return QProcessEnvironment();
} }
virtual QMap<QString, QString> getVariables() const override QMap<QString, QString> getVariables() const override
{ {
return QMap<QString, QString>(); return QMap<QString, QString>();
} }
virtual IPathMatcher::Ptr getLogFileMatcher() override IPathMatcher::Ptr getLogFileMatcher() override
{ {
return nullptr; return nullptr;
} }
virtual QString getLogFileRoot() override QString getLogFileRoot() override
{ {
return instanceRoot(); return instanceRoot();
} }
virtual QString typeName() const override QString typeName() const override
{ {
return "Null"; return "Null";
} }

View File

@ -75,8 +75,8 @@ void JavaChecker::stderrReady()
void JavaChecker::finished(int exitcode, QProcess::ExitStatus status) void JavaChecker::finished(int exitcode, QProcess::ExitStatus status)
{ {
killTimer.stop(); killTimer.stop();
QProcessPtr _process; QProcessPtr _process = process;
_process.swap(process); process.reset();
JavaCheckResult result; JavaCheckResult result;
{ {

View File

@ -3,6 +3,8 @@
#include <QTimer> #include <QTimer>
#include <memory> #include <memory>
#include "QObjectPtr.h"
#include "multimc_logic_export.h" #include "multimc_logic_export.h"
#include "JavaVersion.h" #include "JavaVersion.h"
@ -27,8 +29,8 @@ struct MULTIMC_LOGIC_EXPORT JavaCheckResult
} validity = Validity::Errored; } validity = Validity::Errored;
}; };
typedef std::shared_ptr<QProcess> QProcessPtr; typedef shared_qobject_ptr<QProcess> QProcessPtr;
typedef std::shared_ptr<JavaChecker> JavaCheckerPtr; typedef shared_qobject_ptr<JavaChecker> JavaCheckerPtr;
class MULTIMC_LOGIC_EXPORT JavaChecker : public QObject class MULTIMC_LOGIC_EXPORT JavaChecker : public QObject
{ {
Q_OBJECT Q_OBJECT

View File

@ -20,7 +20,7 @@
#include "tasks/Task.h" #include "tasks/Task.h"
class JavaCheckerJob; class JavaCheckerJob;
typedef std::shared_ptr<JavaCheckerJob> JavaCheckerJobPtr; typedef shared_qobject_ptr<JavaCheckerJob> JavaCheckerJobPtr;
// FIXME: this just seems horribly redundant // FIXME: this just seems horribly redundant
class JavaCheckerJob : public Task class JavaCheckerJob : public Task

View File

@ -149,7 +149,7 @@ void JavaListLoadTask::executeTask()
JavaUtils ju; JavaUtils ju;
QList<QString> candidate_paths = ju.FindJavaPaths(); QList<QString> candidate_paths = ju.FindJavaPaths();
m_job = std::shared_ptr<JavaCheckerJob>(new JavaCheckerJob("Java detection")); m_job = new JavaCheckerJob("Java detection");
connect(m_job.get(), &Task::finished, this, &JavaListLoadTask::javaCheckerFinished); connect(m_job.get(), &Task::finished, this, &JavaListLoadTask::javaCheckerFinished);
connect(m_job.get(), &Task::progress, this, &Task::setProgress); connect(m_job.get(), &Task::progress, this, &Task::setProgress);

View File

@ -24,6 +24,8 @@
#include "JavaCheckerJob.h" #include "JavaCheckerJob.h"
#include "JavaInstall.h" #include "JavaInstall.h"
#include "QObjectPtr.h"
#include "multimc_logic_export.h" #include "multimc_logic_export.h"
class JavaListLoadTask; class JavaListLoadTask;
@ -75,7 +77,7 @@ public slots:
void javaCheckerFinished(); void javaCheckerFinished();
protected: protected:
std::shared_ptr<JavaCheckerJob> m_job; shared_qobject_ptr<JavaCheckerJob> m_job;
JavaInstallList *m_list; JavaInstallList *m_list;
JavaInstall *m_currentRecommended; JavaInstall *m_currentRecommended;
}; };

View File

@ -60,7 +60,7 @@ void CheckJava::executeTask()
// if timestamps are not the same, or something is missing, check! // if timestamps are not the same, or something is missing, check!
if (javaUnixTime != storedUnixTime || storedVersion.size() == 0 || storedArchitecture.size() == 0) if (javaUnixTime != storedUnixTime || storedVersion.size() == 0 || storedArchitecture.size() == 0)
{ {
m_JavaChecker = std::make_shared<JavaChecker>(); m_JavaChecker = new JavaChecker();
emit logLine(tr("Checking Java version..."), MessageLevel::MultiMC); emit logLine(tr("Checking Java version..."), MessageLevel::MultiMC);
connect(m_JavaChecker.get(), &JavaChecker::checkFinished, this, &CheckJava::checkJavaFinished); connect(m_JavaChecker.get(), &JavaChecker::checkFinished, this, &CheckJava::checkJavaFinished);
m_JavaChecker->m_path = realJavaPath; m_JavaChecker->m_path = realJavaPath;

View File

@ -33,9 +33,9 @@ void LaunchTask::init()
m_instance->setRunning(true); m_instance->setRunning(true);
} }
std::shared_ptr<LaunchTask> LaunchTask::create(InstancePtr inst) shared_qobject_ptr<LaunchTask> LaunchTask::create(InstancePtr inst)
{ {
std::shared_ptr<LaunchTask> proc(new LaunchTask(inst)); shared_qobject_ptr<LaunchTask> proc(new LaunchTask(inst));
proc->init(); proc->init();
return proc; return proc;
} }
@ -44,12 +44,12 @@ LaunchTask::LaunchTask(InstancePtr instance): m_instance(instance)
{ {
} }
void LaunchTask::appendStep(std::shared_ptr<LaunchStep> step) void LaunchTask::appendStep(shared_qobject_ptr<LaunchStep> step)
{ {
m_steps.append(step); m_steps.append(step);
} }
void LaunchTask::prependStep(std::shared_ptr<LaunchStep> step) void LaunchTask::prependStep(shared_qobject_ptr<LaunchStep> step)
{ {
m_steps.prepend(step); m_steps.prepend(step);
} }

View File

@ -45,11 +45,11 @@ public:
}; };
public: /* methods */ public: /* methods */
static std::shared_ptr<LaunchTask> create(InstancePtr inst); static shared_qobject_ptr<LaunchTask> create(InstancePtr inst);
virtual ~LaunchTask() {}; virtual ~LaunchTask() {};
void appendStep(std::shared_ptr<LaunchStep> step); void appendStep(shared_qobject_ptr<LaunchStep> step);
void prependStep(std::shared_ptr<LaunchStep> step); void prependStep(shared_qobject_ptr<LaunchStep> step);
void setCensorFilter(QMap<QString, QString> filter); void setCensorFilter(QMap<QString, QString> filter);
InstancePtr instance() InstancePtr instance()
@ -117,7 +117,7 @@ private: /*methods */
protected: /* data */ protected: /* data */
InstancePtr m_instance; InstancePtr m_instance;
shared_qobject_ptr<LogModel> m_logModel; shared_qobject_ptr<LogModel> m_logModel;
QList <std::shared_ptr<LaunchStep>> m_steps; QList <shared_qobject_ptr<LaunchStep>> m_steps;
QMap<QString, QString> m_censorFilter; QMap<QString, QString> m_censorFilter;
int currentStep = -1; int currentStep = -1;
State state = NotStarted; State state = NotStarted;

View File

@ -777,22 +777,22 @@ shared_qobject_ptr<Task> MinecraftInstance::createUpdateTask(Net::Mode mode)
return nullptr; return nullptr;
} }
std::shared_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr session) shared_qobject_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr session)
{ {
auto process = LaunchTask::create(std::dynamic_pointer_cast<MinecraftInstance>(getSharedPtr())); // FIXME: get rid of shared_from_this ...
auto process = LaunchTask::create(std::dynamic_pointer_cast<MinecraftInstance>(shared_from_this()));
auto pptr = process.get(); auto pptr = process.get();
ENV.icons()->saveIcon(iconKey(), FS::PathCombine(gameRoot(), "icon.png"), "PNG"); ENV.icons()->saveIcon(iconKey(), FS::PathCombine(gameRoot(), "icon.png"), "PNG");
// print a header // print a header
{ {
process->appendStep(std::make_shared<TextPrint>(pptr, "Minecraft folder is:\n" + gameRoot() + "\n\n", MessageLevel::MultiMC)); process->appendStep(new TextPrint(pptr, "Minecraft folder is:\n" + gameRoot() + "\n\n", MessageLevel::MultiMC));
} }
// check java // check java
{ {
auto step = std::make_shared<CheckJava>(pptr); process->appendStep(new CheckJava(pptr));
process->appendStep(step);
} }
// check launch method // check launch method
@ -800,14 +800,14 @@ std::shared_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr s
QString method = launchMethod(); QString method = launchMethod();
if(!validMethods.contains(method)) if(!validMethods.contains(method))
{ {
process->appendStep(std::make_shared<TextPrint>(pptr, "Selected launch method \"" + method + "\" is not valid.\n", MessageLevel::Fatal)); process->appendStep(new TextPrint(pptr, "Selected launch method \"" + method + "\" is not valid.\n", MessageLevel::Fatal));
return process; return process;
} }
// run pre-launch command if that's needed // run pre-launch command if that's needed
if(getPreLaunchCommand().size()) if(getPreLaunchCommand().size())
{ {
auto step = std::make_shared<PreLaunchCommand>(pptr); auto step = new PreLaunchCommand(pptr);
step->setWorkingDirectory(gameRoot()); step->setWorkingDirectory(gameRoot());
process->appendStep(step); process->appendStep(step);
} }
@ -815,42 +815,37 @@ std::shared_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr s
// if we aren't in offline mode,. // if we aren't in offline mode,.
if(session->status != AuthSession::PlayableOffline) if(session->status != AuthSession::PlayableOffline)
{ {
process->appendStep(std::make_shared<ClaimAccount>(pptr, session)); process->appendStep(new ClaimAccount(pptr, session));
process->appendStep(std::make_shared<Update>(pptr, Net::Mode::Online)); process->appendStep(new Update(pptr, Net::Mode::Online));
} }
else else
{ {
process->appendStep(std::make_shared<Update>(pptr, Net::Mode::Offline)); process->appendStep(new Update(pptr, Net::Mode::Offline));
} }
// if there are any jar mods // if there are any jar mods
{ {
auto step = std::make_shared<ModMinecraftJar>(pptr); process->appendStep(new ModMinecraftJar(pptr));
process->appendStep(step);
} }
// print some instance info here... // print some instance info here...
{ {
auto step = std::make_shared<PrintInstanceInfo>(pptr, session); process->appendStep(new PrintInstanceInfo(pptr, session));
process->appendStep(step);
} }
// create the server-resource-packs folder (workaround for Minecraft bug MCL-3732) // create the server-resource-packs folder (workaround for Minecraft bug MCL-3732)
{ {
auto step = std::make_shared<CreateServerResourcePacksFolder>(pptr); process->appendStep(new CreateServerResourcePacksFolder(pptr));
process->appendStep(step);
} }
// extract native jars if needed // extract native jars if needed
{ {
auto step = std::make_shared<ExtractNatives>(pptr); process->appendStep(new ExtractNatives(pptr));
process->appendStep(step);
} }
// reconstruct assets if needed // reconstruct assets if needed
{ {
auto step = std::make_shared<ReconstructAssets>(pptr); process->appendStep(new ReconstructAssets(pptr));
process->appendStep(step);
} }
{ {
@ -858,14 +853,14 @@ std::shared_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr s
auto method = launchMethod(); auto method = launchMethod();
if(method == "LauncherPart") if(method == "LauncherPart")
{ {
auto step = std::make_shared<LauncherPartLaunch>(pptr); auto step = new LauncherPartLaunch(pptr);
step->setWorkingDirectory(gameRoot()); step->setWorkingDirectory(gameRoot());
step->setAuthSession(session); step->setAuthSession(session);
process->appendStep(step); process->appendStep(step);
} }
else if (method == "DirectJava") else if (method == "DirectJava")
{ {
auto step = std::make_shared<DirectJavaLaunch>(pptr); auto step = new DirectJavaLaunch(pptr);
step->setWorkingDirectory(gameRoot()); step->setWorkingDirectory(gameRoot());
step->setAuthSession(session); step->setAuthSession(session);
process->appendStep(step); process->appendStep(step);
@ -875,7 +870,7 @@ std::shared_ptr<LaunchTask> MinecraftInstance::createLaunchTask(AuthSessionPtr s
// run post-exit command if that's needed // run post-exit command if that's needed
if(getPostExitCommand().size()) if(getPostExitCommand().size())
{ {
auto step = std::make_shared<PostLaunchCommand>(pptr); auto step = new PostLaunchCommand(pptr);
step->setWorkingDirectory(gameRoot()); step->setWorkingDirectory(gameRoot());
process->appendStep(step); process->appendStep(step);
} }

View File

@ -78,7 +78,7 @@ public:
////// Launch stuff ////// ////// Launch stuff //////
shared_qobject_ptr<Task> createUpdateTask(Net::Mode mode) override; shared_qobject_ptr<Task> createUpdateTask(Net::Mode mode) override;
std::shared_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account) override; shared_qobject_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account) override;
QStringList extraArguments() const override; QStringList extraArguments() const override;
QStringList verboseDescription(AuthSessionPtr session) override; QStringList verboseDescription(AuthSessionPtr session) override;
QList<Mod> getJarMods() const; QList<Mod> getJarMods() const;

View File

@ -17,6 +17,7 @@
#include "BaseInstance.h" #include "BaseInstance.h"
#include "minecraft/Mod.h" #include "minecraft/Mod.h"
#include "launch/LaunchTask.h"
#include "multimc_logic_export.h" #include "multimc_logic_export.h"
@ -112,7 +113,7 @@ public:
{ {
return false; return false;
} }
std::shared_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account) override shared_qobject_ptr<LaunchTask> createLaunchTask(AuthSessionPtr account) override
{ {
return nullptr; return nullptr;
} }

View File

@ -1,4 +1,5 @@
#include "BaseProfiler.h" #include "BaseProfiler.h"
#include "QObjectPtr.h"
#include <QProcess> #include <QProcess>
@ -7,7 +8,7 @@ BaseProfiler::BaseProfiler(SettingsObjectPtr settings, InstancePtr instance, QOb
{ {
} }
void BaseProfiler::beginProfiling(std::shared_ptr<LaunchTask> process) void BaseProfiler::beginProfiling(shared_qobject_ptr<LaunchTask> process)
{ {
beginProfilingImpl(process); beginProfilingImpl(process);
} }

View File

@ -1,6 +1,7 @@
#pragma once #pragma once
#include "BaseExternalTool.h" #include "BaseExternalTool.h"
#include "QObjectPtr.h"
#include "multimc_logic_export.h" #include "multimc_logic_export.h"
@ -17,13 +18,13 @@ public:
public public
slots: slots:
void beginProfiling(std::shared_ptr<LaunchTask> process); void beginProfiling(shared_qobject_ptr<LaunchTask> process);
void abortProfiling(); void abortProfiling();
protected: protected:
QProcess *m_profilerProcess; QProcess *m_profilerProcess;
virtual void beginProfilingImpl(std::shared_ptr<LaunchTask> process) = 0; virtual void beginProfilingImpl(shared_qobject_ptr<LaunchTask> process) = 0;
virtual void abortProfilingImpl(); virtual void abortProfilingImpl();
signals: signals:

View File

@ -17,7 +17,7 @@ private slots:
void profilerFinished(int exit, QProcess::ExitStatus status); void profilerFinished(int exit, QProcess::ExitStatus status);
protected: protected:
void beginProfilingImpl(std::shared_ptr<LaunchTask> process); void beginProfilingImpl(shared_qobject_ptr<LaunchTask> process);
private: private:
int listeningPort = 0; int listeningPort = 0;
@ -47,7 +47,7 @@ void JProfiler::profilerFinished(int exit, QProcess::ExitStatus status)
} }
} }
void JProfiler::beginProfilingImpl(std::shared_ptr<LaunchTask> process) void JProfiler::beginProfilingImpl(shared_qobject_ptr<LaunchTask> process)
{ {
listeningPort = globalSettings->get("JProfilerPort").toInt(); listeningPort = globalSettings->get("JProfilerPort").toInt();
QProcess *profiler = new QProcess(this); QProcess *profiler = new QProcess(this);

View File

@ -18,7 +18,7 @@ private slots:
void profilerFinished(int exit, QProcess::ExitStatus status); void profilerFinished(int exit, QProcess::ExitStatus status);
protected: protected:
void beginProfilingImpl(std::shared_ptr<LaunchTask> process); void beginProfilingImpl(shared_qobject_ptr<LaunchTask> process);
}; };
@ -45,7 +45,7 @@ void JVisualVM::profilerFinished(int exit, QProcess::ExitStatus status)
} }
} }
void JVisualVM::beginProfilingImpl(std::shared_ptr<LaunchTask> process) void JVisualVM::beginProfilingImpl(shared_qobject_ptr<LaunchTask> process)
{ {
QProcess *profiler = new QProcess(this); QProcess *profiler = new QProcess(this);
QStringList profilerArgs = QStringList profilerArgs =

View File

@ -144,7 +144,7 @@ void InstanceWindow::on_btnLaunchMinecraftOffline_clicked()
MMC->launch(m_instance, false, nullptr); MMC->launch(m_instance, false, nullptr);
} }
void InstanceWindow::on_InstanceLaunchTask_changed(std::shared_ptr<LaunchTask> proc) void InstanceWindow::on_InstanceLaunchTask_changed(shared_qobject_ptr<LaunchTask> proc)
{ {
m_proc = proc; m_proc = proc;
} }

View File

@ -52,7 +52,7 @@ slots:
void on_btnKillMinecraft_clicked(); void on_btnKillMinecraft_clicked();
void on_btnLaunchMinecraftOffline_clicked(); void on_btnLaunchMinecraftOffline_clicked();
void on_InstanceLaunchTask_changed(std::shared_ptr<LaunchTask> proc); void on_InstanceLaunchTask_changed(shared_qobject_ptr<LaunchTask> proc);
void on_RunningState_changed(bool running); void on_RunningState_changed(bool running);
void on_instanceStatusChanged(BaseInstance::Status, BaseInstance::Status newStatus); void on_instanceStatusChanged(BaseInstance::Status, BaseInstance::Status newStatus);
@ -63,7 +63,7 @@ private:
void updateLaunchButtons(); void updateLaunchButtons();
private: private:
std::shared_ptr<LaunchTask> m_proc; shared_qobject_ptr<LaunchTask> m_proc;
InstancePtr m_instance; InstancePtr m_instance;
bool m_doNotSave = false; bool m_doNotSave = false;
PageContainer *m_container = nullptr; PageContainer *m_container = nullptr;

View File

@ -218,7 +218,7 @@ void LaunchController::launchInstance()
connect(m_launcher.get(), &LaunchTask::requestProgress, this, &LaunchController::onProgressRequested); connect(m_launcher.get(), &LaunchTask::requestProgress, this, &LaunchController::onProgressRequested);
m_launcher->prependStep(std::make_shared<TextPrint>(m_launcher.get(), "MultiMC version: " + BuildConfig.printableVersionString() + "\n\n", MessageLevel::MultiMC)); m_launcher->prependStep(new TextPrint(m_launcher.get(), "MultiMC version: " + BuildConfig.printableVersionString() + "\n\n", MessageLevel::MultiMC));
m_launcher->start(); m_launcher->start();
} }

View File

@ -57,5 +57,5 @@ private:
QWidget * m_parentWidget = nullptr; QWidget * m_parentWidget = nullptr;
InstanceWindow *m_console = nullptr; InstanceWindow *m_console = nullptr;
AuthSessionPtr m_session; AuthSessionPtr m_session;
std::shared_ptr <LaunchTask> m_launcher; shared_qobject_ptr<LaunchTask> m_launcher;
}; };

View File

@ -192,7 +192,7 @@ void LogPage::UIToModelState()
m_model->suspend(ui->trackLogCheckbox->checkState() != Qt::Checked); m_model->suspend(ui->trackLogCheckbox->checkState() != Qt::Checked);
} }
void LogPage::setInstanceLaunchTaskChanged(std::shared_ptr<LaunchTask> proc, bool initial) void LogPage::setInstanceLaunchTaskChanged(shared_qobject_ptr<LaunchTask> proc, bool initial)
{ {
m_process = proc; m_process = proc;
if(m_process) if(m_process)
@ -215,7 +215,7 @@ void LogPage::setInstanceLaunchTaskChanged(std::shared_ptr<LaunchTask> proc, boo
} }
} }
void LogPage::onInstanceLaunchTaskChanged(std::shared_ptr<LaunchTask> proc) void LogPage::onInstanceLaunchTaskChanged(shared_qobject_ptr<LaunchTask> proc)
{ {
setInstanceLaunchTaskChanged(proc, false); setInstanceLaunchTaskChanged(proc, false);
} }

View File

@ -69,17 +69,17 @@ private slots:
void findNextActivated(); void findNextActivated();
void findPreviousActivated(); void findPreviousActivated();
void onInstanceLaunchTaskChanged(std::shared_ptr<LaunchTask> proc); void onInstanceLaunchTaskChanged(shared_qobject_ptr<LaunchTask> proc);
private: private:
void modelStateToUI(); void modelStateToUI();
void UIToModelState(); void UIToModelState();
void setInstanceLaunchTaskChanged(std::shared_ptr<LaunchTask> proc, bool initial); void setInstanceLaunchTaskChanged(shared_qobject_ptr<LaunchTask> proc, bool initial);
private: private:
Ui::LogPage *ui; Ui::LogPage *ui;
InstancePtr m_instance; InstancePtr m_instance;
std::shared_ptr<LaunchTask> m_process; shared_qobject_ptr<LaunchTask> m_process;
LogFormatProxyModel * m_proxy; LogFormatProxyModel * m_proxy;
shared_qobject_ptr <LogModel> m_model; shared_qobject_ptr <LogModel> m_model;