Fix many memory leaks.
This commit is contained in:
parent
e1e1d99102
commit
fbc29b6a06
@ -269,27 +269,32 @@ MainWindow::MainWindow(QWidget *parent) : QMainWindow(parent), ui(new Ui::MainWi
|
||||
|
||||
auto accounts = MMC->accounts();
|
||||
|
||||
// TODO: Nicer way to iterate?
|
||||
QList<CacheDownloadPtr> skin_dls;
|
||||
for (int i = 0; i < accounts->count(); i++)
|
||||
{
|
||||
auto account = accounts->at(i);
|
||||
if (account != nullptr)
|
||||
{
|
||||
auto job = new NetJob("Startup player skins: " + account->username());
|
||||
|
||||
for (auto profile : account->profiles())
|
||||
{
|
||||
auto meta = MMC->metacache()->resolveEntry("skins", profile.name + ".png");
|
||||
auto action = CacheDownload::make(
|
||||
QUrl("http://" + URLConstants::SKINS_BASE + profile.name + ".png"), meta);
|
||||
job->addNetAction(action);
|
||||
skin_dls.append(action);
|
||||
meta->stale = true;
|
||||
}
|
||||
|
||||
connect(job, SIGNAL(succeeded()), SLOT(activeAccountChanged()));
|
||||
job->start();
|
||||
}
|
||||
}
|
||||
if(!skin_dls.isEmpty())
|
||||
{
|
||||
auto job = new NetJob("Startup player skins download");
|
||||
connect(job, SIGNAL(succeeded()), SLOT(skinJobFinished()));
|
||||
connect(job, SIGNAL(failed()), SLOT(skinJobFinished()));
|
||||
for(auto action: skin_dls)
|
||||
job->addNetAction(action);
|
||||
skin_download_job.reset(job);
|
||||
job->start();
|
||||
}
|
||||
|
||||
// run the things that load and download other things... FIXME: this is NOT the place
|
||||
// FIXME: invisible actions in the background = NOPE.
|
||||
@ -338,6 +343,13 @@ MainWindow::~MainWindow()
|
||||
delete proxymodel;
|
||||
}
|
||||
|
||||
void MainWindow::skinJobFinished()
|
||||
{
|
||||
activeAccountChanged();
|
||||
skin_download_job.reset();
|
||||
}
|
||||
|
||||
|
||||
void MainWindow::showInstanceContextMenu(const QPoint &pos)
|
||||
{
|
||||
if (!view->indexAt(pos).isValid())
|
||||
@ -748,7 +760,7 @@ void MainWindow::on_actionAddInstance_triggered()
|
||||
if (!newInstDlg.exec())
|
||||
return;
|
||||
|
||||
BaseInstance *newInstance = NULL;
|
||||
InstancePtr newInstance;
|
||||
|
||||
QString instancesDir = MMC->settings()->get("InstanceDir").toString();
|
||||
QString instDirName = DirNameFromString(newInstDlg.instName(), instancesDir);
|
||||
@ -825,7 +837,7 @@ void MainWindow::on_actionCopyInstance_triggered()
|
||||
|
||||
auto &loader = InstanceFactory::get();
|
||||
|
||||
BaseInstance *newInstance = NULL;
|
||||
InstancePtr newInstance;
|
||||
auto error = loader.copyInstance(newInstance, m_selectedInstance, instDir);
|
||||
|
||||
QString errorMsg = tr("Failed to create instance %1: ").arg(instDirName);
|
||||
@ -834,7 +846,7 @@ void MainWindow::on_actionCopyInstance_triggered()
|
||||
case InstanceFactory::NoCreateError:
|
||||
newInstance->setName(copyInstDlg.instName());
|
||||
newInstance->setIconKey(copyInstDlg.iconKey());
|
||||
MMC->instances()->add(InstancePtr(newInstance));
|
||||
MMC->instances()->add(newInstance);
|
||||
return;
|
||||
|
||||
case InstanceFactory::InstExists:
|
||||
@ -1084,9 +1096,10 @@ void MainWindow::instanceActivated(QModelIndex index)
|
||||
{
|
||||
if (!index.isValid())
|
||||
return;
|
||||
|
||||
BaseInstance *inst =
|
||||
(BaseInstance *)index.data(InstanceList::InstancePointerRole).value<void *>();
|
||||
QString id = index.data(InstanceList::InstanceIDRole).toString();
|
||||
InstancePtr inst = MMC->instances()->getInstanceById(id);
|
||||
if(!inst)
|
||||
return;
|
||||
|
||||
NagUtils::checkJVMArgs(inst->settings().get("JvmArgs").toString(), this);
|
||||
|
||||
@ -1239,7 +1252,7 @@ void MainWindow::doLaunch(bool online, BaseProfilerFactory *profiler)
|
||||
}
|
||||
}
|
||||
|
||||
void MainWindow::updateInstance(BaseInstance *instance, AuthSessionPtr session, BaseProfilerFactory *profiler)
|
||||
void MainWindow::updateInstance(InstancePtr instance, AuthSessionPtr session, BaseProfilerFactory *profiler)
|
||||
{
|
||||
auto updateTask = instance->doUpdate();
|
||||
if (!updateTask)
|
||||
@ -1254,7 +1267,7 @@ void MainWindow::updateInstance(BaseInstance *instance, AuthSessionPtr session,
|
||||
tDialog.exec(updateTask.get());
|
||||
}
|
||||
|
||||
void MainWindow::launchInstance(BaseInstance *instance, AuthSessionPtr session, BaseProfilerFactory *profiler)
|
||||
void MainWindow::launchInstance(InstancePtr instance, AuthSessionPtr session, BaseProfilerFactory *profiler)
|
||||
{
|
||||
Q_ASSERT_X(instance != NULL, "launchInstance", "instance is NULL");
|
||||
Q_ASSERT_X(session.get() != nullptr, "launchInstance", "session is NULL");
|
||||
@ -1427,8 +1440,9 @@ void MainWindow::on_actionChangeInstLWJGLVersion_triggered()
|
||||
lselect.exec();
|
||||
if (lselect.result() == QDialog::Accepted)
|
||||
{
|
||||
LegacyInstance *linst = (LegacyInstance *)m_selectedInstance;
|
||||
linst->setLWJGLVersion(lselect.selectedVersion());
|
||||
auto ptr = std::dynamic_pointer_cast<LegacyInstance>(m_selectedInstance);
|
||||
if(ptr)
|
||||
ptr->setLWJGLVersion(lselect.selectedVersion());
|
||||
}
|
||||
}
|
||||
|
||||
@ -1444,10 +1458,15 @@ void MainWindow::on_actionInstanceSettings_triggered()
|
||||
|
||||
void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
||||
{
|
||||
if (current.isValid() &&
|
||||
nullptr != (m_selectedInstance =
|
||||
(BaseInstance *)current.data(InstanceList::InstancePointerRole)
|
||||
.value<void *>()))
|
||||
if(!current.isValid())
|
||||
{
|
||||
selectionBad();
|
||||
MMC->settings()->set("SelectedInstance", QString());
|
||||
return;
|
||||
}
|
||||
QString id = current.data(InstanceList::InstanceIDRole).toString();
|
||||
m_selectedInstance = MMC->instances()->getInstanceById(id);
|
||||
if ( m_selectedInstance )
|
||||
{
|
||||
ui->instanceToolBar->setEnabled(m_selectedInstance->canLaunch());
|
||||
renameButton->setText(m_selectedInstance->name());
|
||||
@ -1466,9 +1485,9 @@ void MainWindow::instanceChanged(const QModelIndex ¤t, const QModelIndex &
|
||||
}
|
||||
else
|
||||
{
|
||||
selectionBad();
|
||||
|
||||
MMC->settings()->set("SelectedInstance", QString());
|
||||
selectionBad();
|
||||
MMC->settings()->set("SelectedInstance", QString());
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
@ -1490,14 +1509,13 @@ void MainWindow::on_actionEditInstNotes_triggered()
|
||||
{
|
||||
if (!m_selectedInstance)
|
||||
return;
|
||||
LegacyInstance *linst = (LegacyInstance *)m_selectedInstance;
|
||||
|
||||
EditNotesDialog noteedit(linst->notes(), linst->name(), this);
|
||||
EditNotesDialog noteedit(m_selectedInstance->notes(), m_selectedInstance->name(), this);
|
||||
noteedit.exec();
|
||||
if (noteedit.result() == QDialog::Accepted)
|
||||
{
|
||||
|
||||
linst->setNotes(noteedit.getText());
|
||||
m_selectedInstance->setNotes(noteedit.getText());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -23,6 +23,7 @@
|
||||
#include "logic/BaseInstance.h"
|
||||
|
||||
#include "logic/auth/MojangAccount.h"
|
||||
#include <logic/net/NetJob.h>
|
||||
|
||||
class QToolButton;
|
||||
class LabeledToolButton;
|
||||
@ -118,12 +119,12 @@ slots:
|
||||
* Launches the given instance with the given account.
|
||||
* This function assumes that the given account has a valid, usable access token.
|
||||
*/
|
||||
void launchInstance(BaseInstance *instance, AuthSessionPtr session, BaseProfilerFactory *profiler = 0);
|
||||
void launchInstance(InstancePtr instance, AuthSessionPtr session, BaseProfilerFactory *profiler = 0);
|
||||
|
||||
/*!
|
||||
* Prepares the given instance for launch with the given account.
|
||||
*/
|
||||
void updateInstance(BaseInstance *instance, AuthSessionPtr account, BaseProfilerFactory *profiler = 0);
|
||||
void updateInstance(InstancePtr instance, AuthSessionPtr account, BaseProfilerFactory *profiler = 0);
|
||||
|
||||
void onGameUpdateError(QString error);
|
||||
|
||||
@ -145,6 +146,7 @@ slots:
|
||||
|
||||
void updateToolsMenu();
|
||||
|
||||
void skinJobFinished();
|
||||
public
|
||||
slots:
|
||||
void instanceActivated(QModelIndex);
|
||||
@ -189,13 +191,14 @@ private:
|
||||
Ui::MainWindow *ui;
|
||||
class GroupView *view;
|
||||
InstanceProxyModel *proxymodel;
|
||||
NetJobPtr skin_download_job;
|
||||
MinecraftProcess *proc;
|
||||
ConsoleWindow *console;
|
||||
LabeledToolButton *renameButton;
|
||||
QToolButton *changeIconButton;
|
||||
QToolButton *newsLabel;
|
||||
|
||||
BaseInstance *m_selectedInstance;
|
||||
InstancePtr m_selectedInstance;
|
||||
QString m_currentInstIcon;
|
||||
|
||||
Task *m_versionLoadTask;
|
||||
|
@ -32,7 +32,7 @@
|
||||
#include "logic/tasks/Task.h"
|
||||
#include "logic/BaseInstance.h"
|
||||
|
||||
CopyInstanceDialog::CopyInstanceDialog(BaseInstance *original, QWidget *parent)
|
||||
CopyInstanceDialog::CopyInstanceDialog(InstancePtr original, QWidget *parent)
|
||||
:QDialog(parent), ui(new Ui::CopyInstanceDialog), m_original(original)
|
||||
{
|
||||
MultiMCPlatform::fixWM_CLASS(this);
|
||||
|
@ -17,6 +17,7 @@
|
||||
|
||||
#include <QDialog>
|
||||
#include "logic/BaseVersion.h"
|
||||
#include <logic/BaseInstance.h>
|
||||
|
||||
class BaseInstance;
|
||||
|
||||
@ -30,7 +31,7 @@ class CopyInstanceDialog : public QDialog
|
||||
Q_OBJECT
|
||||
|
||||
public:
|
||||
explicit CopyInstanceDialog(BaseInstance *original, QWidget *parent = 0);
|
||||
explicit CopyInstanceDialog(InstancePtr original, QWidget *parent = 0);
|
||||
~CopyInstanceDialog();
|
||||
|
||||
void updateDialogState();
|
||||
@ -46,5 +47,5 @@ slots:
|
||||
private:
|
||||
Ui::CopyInstanceDialog *ui;
|
||||
QString InstIconKey;
|
||||
BaseInstance *m_original;
|
||||
InstancePtr m_original;
|
||||
};
|
||||
|
@ -317,6 +317,7 @@ void ListViewDelegate::paint(QPainter *painter, const QStyleOptionViewItem &opti
|
||||
line.draw(painter, position);
|
||||
}
|
||||
|
||||
// FIXME: this really has no business of being here. Make generic.
|
||||
auto instance = (BaseInstance*)index.data(InstanceList::InstancePointerRole)
|
||||
.value<void *>();
|
||||
if (instance)
|
||||
|
@ -24,8 +24,10 @@
|
||||
|
||||
#define I_D(Class) Class##Private *const d = (Class##Private * const)inst_d.get()
|
||||
|
||||
struct BaseInstancePrivate
|
||||
class BaseInstancePrivate
|
||||
{
|
||||
public:
|
||||
virtual ~BaseInstancePrivate(){};
|
||||
QString m_rootDir;
|
||||
QString m_group;
|
||||
std::shared_ptr<SettingsObject> m_settings;
|
||||
|
@ -41,7 +41,7 @@ InstanceFactory::InstanceFactory() : QObject(NULL)
|
||||
{
|
||||
}
|
||||
|
||||
InstanceFactory::InstLoadError InstanceFactory::loadInstance(BaseInstance *&inst,
|
||||
InstanceFactory::InstLoadError InstanceFactory::loadInstance(InstancePtr &inst,
|
||||
const QString &instDir)
|
||||
{
|
||||
auto m_settings = new INISettingsObject(PathCombine(instDir, "instance.cfg"));
|
||||
@ -53,23 +53,23 @@ InstanceFactory::InstLoadError InstanceFactory::loadInstance(BaseInstance *&inst
|
||||
// FIXME: replace with a map lookup, where instance classes register their types
|
||||
if (inst_type == "OneSix")
|
||||
{
|
||||
inst = new OneSixInstance(instDir, m_settings, this);
|
||||
inst.reset(new OneSixInstance(instDir, m_settings, this));
|
||||
}
|
||||
else if (inst_type == "Legacy")
|
||||
{
|
||||
inst = new LegacyInstance(instDir, m_settings, this);
|
||||
inst.reset(new LegacyInstance(instDir, m_settings, this));
|
||||
}
|
||||
else if (inst_type == "Nostalgia")
|
||||
{
|
||||
inst = new NostalgiaInstance(instDir, m_settings, this);
|
||||
inst.reset(new NostalgiaInstance(instDir, m_settings, this));
|
||||
}
|
||||
else if (inst_type == "LegacyFTB")
|
||||
{
|
||||
inst = new LegacyFTBInstance(instDir, m_settings, this);
|
||||
inst.reset(new LegacyFTBInstance(instDir, m_settings, this));
|
||||
}
|
||||
else if (inst_type == "OneSixFTB")
|
||||
{
|
||||
inst = new OneSixFTBInstance(instDir, m_settings, this);
|
||||
inst.reset(new OneSixFTBInstance(instDir, m_settings, this));
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -79,10 +79,8 @@ InstanceFactory::InstLoadError InstanceFactory::loadInstance(BaseInstance *&inst
|
||||
return NoLoadError;
|
||||
}
|
||||
|
||||
InstanceFactory::InstCreateError InstanceFactory::createInstance(BaseInstance *&inst,
|
||||
BaseVersionPtr version,
|
||||
const QString &instDir,
|
||||
const InstType type)
|
||||
InstanceFactory::InstCreateError InstanceFactory::createInstance(InstancePtr &inst, BaseVersionPtr version,
|
||||
const QString &instDir, const InstanceFactory::InstType type)
|
||||
{
|
||||
QDir rootDir(instDir);
|
||||
|
||||
@ -105,19 +103,19 @@ InstanceFactory::InstCreateError InstanceFactory::createInstance(BaseInstance *&
|
||||
case MinecraftVersion::Legacy:
|
||||
// TODO new instance type
|
||||
m_settings->set("InstanceType", "Legacy");
|
||||
inst = new LegacyInstance(instDir, m_settings, this);
|
||||
inst.reset(new LegacyInstance(instDir, m_settings, this));
|
||||
inst->setIntendedVersionId(version->descriptor());
|
||||
inst->setShouldUseCustomBaseJar(false);
|
||||
break;
|
||||
case MinecraftVersion::OneSix:
|
||||
m_settings->set("InstanceType", "OneSix");
|
||||
inst = new OneSixInstance(instDir, m_settings, this);
|
||||
inst.reset(new OneSixInstance(instDir, m_settings, this));
|
||||
inst->setIntendedVersionId(version->descriptor());
|
||||
inst->setShouldUseCustomBaseJar(false);
|
||||
break;
|
||||
case MinecraftVersion::Nostalgia:
|
||||
m_settings->set("InstanceType", "Nostalgia");
|
||||
inst = new NostalgiaInstance(instDir, m_settings, this);
|
||||
inst.reset(new NostalgiaInstance(instDir, m_settings, this));
|
||||
inst->setIntendedVersionId(version->descriptor());
|
||||
inst->setShouldUseCustomBaseJar(false);
|
||||
break;
|
||||
@ -134,13 +132,13 @@ InstanceFactory::InstCreateError InstanceFactory::createInstance(BaseInstance *&
|
||||
{
|
||||
case MinecraftVersion::Legacy:
|
||||
m_settings->set("InstanceType", "LegacyFTB");
|
||||
inst = new LegacyFTBInstance(instDir, m_settings, this);
|
||||
inst.reset(new LegacyFTBInstance(instDir, m_settings, this));
|
||||
inst->setIntendedVersionId(version->descriptor());
|
||||
inst->setShouldUseCustomBaseJar(false);
|
||||
break;
|
||||
case MinecraftVersion::OneSix:
|
||||
m_settings->set("InstanceType", "OneSixFTB");
|
||||
inst = new OneSixFTBInstance(instDir, m_settings, this);
|
||||
inst.reset(new OneSixFTBInstance(instDir, m_settings, this));
|
||||
inst->setIntendedVersionId(version->descriptor());
|
||||
inst->setShouldUseCustomBaseJar(false);
|
||||
break;
|
||||
@ -163,8 +161,8 @@ InstanceFactory::InstCreateError InstanceFactory::createInstance(BaseInstance *&
|
||||
return InstanceFactory::NoCreateError;
|
||||
}
|
||||
|
||||
InstanceFactory::InstCreateError InstanceFactory::copyInstance(BaseInstance *&newInstance,
|
||||
BaseInstance *&oldInstance,
|
||||
InstanceFactory::InstCreateError InstanceFactory::copyInstance(InstancePtr &newInstance,
|
||||
InstancePtr &oldInstance,
|
||||
const QString &instDir)
|
||||
{
|
||||
QDir rootDir(instDir);
|
||||
@ -175,14 +173,6 @@ InstanceFactory::InstCreateError InstanceFactory::copyInstance(BaseInstance *&ne
|
||||
rootDir.removeRecursively();
|
||||
return InstanceFactory::CantCreateDir;
|
||||
}
|
||||
auto m_settings = new INISettingsObject(PathCombine(instDir, "instance.cfg"));
|
||||
m_settings->registerSetting("InstanceType", "Legacy");
|
||||
QString inst_type = m_settings->get("InstanceType").toString();
|
||||
|
||||
if(inst_type == "OneSixFTB")
|
||||
m_settings->set("InstanceType", "OneSix");
|
||||
if(inst_type == "LegacyFTB")
|
||||
m_settings->set("InstanceType", "Legacy");
|
||||
|
||||
oldInstance->copy(instDir);
|
||||
|
||||
@ -198,6 +188,7 @@ InstanceFactory::InstCreateError InstanceFactory::copyInstance(BaseInstance *&ne
|
||||
default:
|
||||
case UnknownLoadError:
|
||||
rootDir.removeRecursively();
|
||||
return UnknownCreateError;
|
||||
return UnknownCreateError;
|
||||
}
|
||||
return UnknownCreateError;
|
||||
}
|
||||
|
@ -20,6 +20,7 @@
|
||||
#include <QList>
|
||||
|
||||
#include "BaseVersion.h"
|
||||
#include "BaseInstance.h"
|
||||
|
||||
class BaseVersion;
|
||||
class BaseInstance;
|
||||
@ -72,7 +73,7 @@ public:
|
||||
* - InstExists if the given instance directory is already an instance.
|
||||
* - CantCreateDir if the given instance directory cannot be created.
|
||||
*/
|
||||
InstCreateError createInstance(BaseInstance *&inst, BaseVersionPtr version,
|
||||
InstCreateError createInstance(InstancePtr &inst, BaseVersionPtr version,
|
||||
const QString &instDir, const InstType type = NormalInst);
|
||||
|
||||
/*!
|
||||
@ -85,7 +86,7 @@ public:
|
||||
* - InstExists if the given instance directory is already an instance.
|
||||
* - CantCreateDir if the given instance directory cannot be created.
|
||||
*/
|
||||
InstCreateError copyInstance(BaseInstance *&newInstance, BaseInstance *&oldInstance,
|
||||
InstCreateError copyInstance(InstancePtr &newInstance, InstancePtr &oldInstance,
|
||||
const QString &instDir);
|
||||
|
||||
/*!
|
||||
@ -96,7 +97,7 @@ public:
|
||||
* \return An InstLoadError error code.
|
||||
* - NotAnInstance if the given instance directory isn't a valid instance.
|
||||
*/
|
||||
InstLoadError loadInstance(BaseInstance *&inst, const QString &instDir);
|
||||
InstLoadError loadInstance(InstancePtr &inst, const QString &instDir);
|
||||
|
||||
private:
|
||||
InstanceFactory();
|
||||
|
@ -21,8 +21,10 @@
|
||||
#include "BaseInstance_p.h"
|
||||
#include "ModList.h"
|
||||
|
||||
struct LegacyInstancePrivate : public BaseInstancePrivate
|
||||
class LegacyInstancePrivate : public BaseInstancePrivate
|
||||
{
|
||||
public:
|
||||
virtual ~LegacyInstancePrivate() {};
|
||||
std::shared_ptr<ModList> jar_mod_list;
|
||||
std::shared_ptr<ModList> core_mod_list;
|
||||
std::shared_ptr<ModList> loader_mod_list;
|
||||
|
@ -23,6 +23,7 @@ class NostalgiaInstance : public OneSixInstance
|
||||
public:
|
||||
explicit NostalgiaInstance(const QString &rootDir, SettingsObject *settings,
|
||||
QObject *parent = 0);
|
||||
virtual ~NostalgiaInstance() {};
|
||||
virtual QString getStatusbarDescription();
|
||||
virtual bool menuActionEnabled(QString action_name) const;
|
||||
};
|
||||
|
@ -10,6 +10,7 @@ class OneSixFTBInstance : public OneSixInstance
|
||||
public:
|
||||
explicit OneSixFTBInstance(const QString &rootDir, SettingsObject *settings,
|
||||
QObject *parent = 0);
|
||||
virtual ~OneSixFTBInstance(){};
|
||||
|
||||
void init() override;
|
||||
void copy(const QDir &newDir) override;
|
||||
|
@ -26,6 +26,7 @@ class OneSixInstance : public BaseInstance
|
||||
public:
|
||||
explicit OneSixInstance(const QString &rootDir, SettingsObject *settings,
|
||||
QObject *parent = 0);
|
||||
virtual ~OneSixInstance(){};
|
||||
|
||||
virtual void init() override;
|
||||
|
||||
|
@ -19,8 +19,10 @@
|
||||
#include "VersionFinal.h"
|
||||
#include "ModList.h"
|
||||
|
||||
struct OneSixInstancePrivate : public BaseInstancePrivate
|
||||
class OneSixInstancePrivate : public BaseInstancePrivate
|
||||
{
|
||||
public:
|
||||
virtual ~OneSixInstancePrivate() {};
|
||||
std::shared_ptr<VersionFinal> version;
|
||||
std::shared_ptr<VersionFinal> vanillaVersion;
|
||||
std::shared_ptr<ModList> loader_mod_list;
|
||||
|
@ -90,6 +90,10 @@ QVariant InstanceList::data(const QModelIndex &index, int role) const
|
||||
QVariant v = qVariantFromValue((void *)pdata);
|
||||
return v;
|
||||
}
|
||||
case InstanceIDRole:
|
||||
{
|
||||
return pdata->id();
|
||||
}
|
||||
case Qt::DisplayRole:
|
||||
{
|
||||
return pdata->name();
|
||||
@ -378,7 +382,7 @@ void InstanceList::loadFTBInstances(QMap<QString, QString> &groupMap,
|
||||
if (!QFileInfo(PathCombine(record.instanceDir, "instance.cfg")).exists())
|
||||
{
|
||||
QLOG_INFO() << "Converting " << record.name << " as new.";
|
||||
BaseInstance *instPtr = NULL;
|
||||
InstancePtr instPtr;
|
||||
auto &factory = InstanceFactory::get();
|
||||
auto version = MMC->minecraftlist()->findVersion(record.mcVersion);
|
||||
if (!version)
|
||||
@ -406,7 +410,7 @@ void InstanceList::loadFTBInstances(QMap<QString, QString> &groupMap,
|
||||
else
|
||||
{
|
||||
QLOG_INFO() << "Loading existing " << record.name;
|
||||
BaseInstance *instPtr = NULL;
|
||||
InstancePtr instPtr;
|
||||
auto error = InstanceFactory::get().loadInstance(instPtr, record.instanceDir);
|
||||
if (!instPtr || error != InstanceFactory::NoLoadError)
|
||||
continue;
|
||||
@ -439,11 +443,11 @@ InstanceList::InstListError InstanceList::loadList()
|
||||
if (!QFileInfo(PathCombine(subDir, "instance.cfg")).exists())
|
||||
continue;
|
||||
QLOG_INFO() << "Loading MultiMC instance from " << subDir;
|
||||
BaseInstance *instPtr = NULL;
|
||||
InstancePtr instPtr;
|
||||
auto error = InstanceFactory::get().loadInstance(instPtr, subDir);
|
||||
if(!continueProcessInstance(instPtr, error, subDir, groupMap))
|
||||
continue;
|
||||
tempList.append(InstancePtr(instPtr));
|
||||
tempList.append(instPtr);
|
||||
}
|
||||
}
|
||||
|
||||
@ -536,7 +540,7 @@ int InstanceList::getInstIndex(BaseInstance *inst) const
|
||||
return -1;
|
||||
}
|
||||
|
||||
bool InstanceList::continueProcessInstance(BaseInstance *instPtr, const int error,
|
||||
bool InstanceList::continueProcessInstance(InstancePtr instPtr, const int error,
|
||||
const QDir &dir, QMap<QString, QString> &groupMap)
|
||||
{
|
||||
if (error != InstanceFactory::NoLoadError && error != InstanceFactory::NotAnInstance)
|
||||
|
@ -62,7 +62,8 @@ public:
|
||||
|
||||
enum AdditionalRoles
|
||||
{
|
||||
InstancePointerRole = 0x34B1CB48 ///< Return pointer to real instance
|
||||
InstancePointerRole = 0x34B1CB48, ///< Return pointer to real instance
|
||||
InstanceIDRole = 0x34B1CB49 ///< Return id if the instance
|
||||
};
|
||||
/*!
|
||||
* \brief Error codes returned by functions in the InstanceList class.
|
||||
@ -132,7 +133,7 @@ slots:
|
||||
private:
|
||||
int getInstIndex(BaseInstance *inst) const;
|
||||
|
||||
bool continueProcessInstance(BaseInstance *instPtr, const int error, const QDir &dir,
|
||||
bool continueProcessInstance(InstancePtr instPtr, const int error, const QDir &dir,
|
||||
QMap<QString, QString> &groupMap);
|
||||
|
||||
protected:
|
||||
|
@ -26,7 +26,7 @@ public:
|
||||
{
|
||||
return ByteArrayDownloadPtr(new ByteArrayDownload(url));
|
||||
}
|
||||
|
||||
virtual ~ByteArrayDownload() {};
|
||||
public:
|
||||
/// if not saving to file, downloaded data is placed here
|
||||
QByteArray m_data;
|
||||
|
@ -41,6 +41,7 @@ public:
|
||||
{
|
||||
return CacheDownloadPtr(new CacheDownload(url, entry));
|
||||
}
|
||||
virtual ~CacheDownload(){};
|
||||
QString getTargetFilepath()
|
||||
{
|
||||
return m_target_path;
|
||||
|
@ -39,7 +39,7 @@ public:
|
||||
{
|
||||
return ForgeMirrorsPtr(new ForgeMirrors(libs, parent_job, mirrorlist));
|
||||
}
|
||||
|
||||
virtual ~ForgeMirrors(){};
|
||||
protected
|
||||
slots:
|
||||
virtual void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
|
||||
|
@ -45,6 +45,7 @@ public:
|
||||
{
|
||||
return ForgeXzDownloadPtr(new ForgeXzDownload(relative_path, entry));
|
||||
}
|
||||
virtual ~ForgeXzDownload(){};
|
||||
void setMirrors(QList<ForgeMirror> & mirrors);
|
||||
|
||||
protected
|
||||
|
@ -38,6 +38,7 @@ public:
|
||||
{
|
||||
return Md5EtagDownloadPtr(new MD5EtagDownload(url, target_path));
|
||||
}
|
||||
virtual ~MD5EtagDownload(){};
|
||||
protected
|
||||
slots:
|
||||
virtual void downloadProgress(qint64 bytesReceived, qint64 bytesTotal);
|
||||
|
@ -32,7 +32,7 @@ class NetJob : public ProgressProvider
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit NetJob(QString job_name) : ProgressProvider(), m_job_name(job_name) {};
|
||||
|
||||
virtual ~NetJob() {};
|
||||
template <typename T> bool addNetAction(T action)
|
||||
{
|
||||
NetActionPtr base = std::static_pointer_cast<NetAction>(action);
|
||||
|
@ -9,6 +9,7 @@ class PasteUpload : public Task
|
||||
Q_OBJECT
|
||||
public:
|
||||
PasteUpload(QWidget *window, QString text);
|
||||
virtual ~PasteUpload(){};
|
||||
|
||||
protected:
|
||||
virtual void executeTask();
|
||||
|
@ -7,7 +7,7 @@
|
||||
#include "gui/dialogs/ProgressDialog.h"
|
||||
#include "gui/dialogs/CustomMessageBox.h"
|
||||
|
||||
ScreenshotList::ScreenshotList(BaseInstance *instance, QObject *parent)
|
||||
ScreenshotList::ScreenshotList(InstancePtr instance, QObject *parent)
|
||||
: QAbstractListModel(parent), m_instance(instance)
|
||||
{
|
||||
}
|
||||
|
@ -10,7 +10,7 @@ class ScreenshotList : public QAbstractListModel
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
ScreenshotList(BaseInstance *instance, QObject *parent = 0);
|
||||
ScreenshotList(InstancePtr instance, QObject *parent = 0);
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const;
|
||||
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
|
||||
@ -31,7 +31,7 @@ public:
|
||||
return m_screenshots;
|
||||
}
|
||||
|
||||
BaseInstance *instance() const
|
||||
InstancePtr instance() const
|
||||
{
|
||||
return m_instance;
|
||||
}
|
||||
@ -45,7 +45,7 @@ slots:
|
||||
|
||||
private:
|
||||
QList<ScreenshotPtr> m_screenshots;
|
||||
BaseInstance *m_instance;
|
||||
InstancePtr m_instance;
|
||||
};
|
||||
|
||||
class ScreenshotLoadTask : public Task
|
||||
|
@ -24,6 +24,7 @@ class Task : public ProgressProvider
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit Task(QObject *parent = 0);
|
||||
virtual ~Task() {};
|
||||
|
||||
virtual QString getStatus() const;
|
||||
virtual void getProgress(qint64 ¤t, qint64 &total);
|
||||
|
@ -11,7 +11,7 @@
|
||||
#include "logic/BaseInstance.h"
|
||||
#include "MultiMC.h"
|
||||
|
||||
BaseExternalTool::BaseExternalTool(BaseInstance *instance, QObject *parent)
|
||||
BaseExternalTool::BaseExternalTool(InstancePtr instance, QObject *parent)
|
||||
: QObject(parent), m_instance(instance)
|
||||
{
|
||||
}
|
||||
@ -55,7 +55,7 @@ QString BaseExternalTool::getSave() const
|
||||
}
|
||||
|
||||
|
||||
BaseDetachedTool::BaseDetachedTool(BaseInstance *instance, QObject *parent)
|
||||
BaseDetachedTool::BaseDetachedTool(InstancePtr instance, QObject *parent)
|
||||
: BaseExternalTool(instance, parent)
|
||||
{
|
||||
|
||||
@ -71,7 +71,8 @@ BaseExternalToolFactory::~BaseExternalToolFactory()
|
||||
{
|
||||
}
|
||||
|
||||
BaseDetachedTool *BaseDetachedToolFactory::createDetachedTool(BaseInstance *instance, QObject *parent)
|
||||
BaseDetachedTool *BaseDetachedToolFactory::createDetachedTool(InstancePtr instance,
|
||||
QObject *parent)
|
||||
{
|
||||
return qobject_cast<BaseDetachedTool *>(createTool(instance, parent));
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
#pragma once
|
||||
|
||||
#include <QObject>
|
||||
#include <logic/BaseInstance.h>
|
||||
|
||||
class BaseInstance;
|
||||
class SettingsObject;
|
||||
@ -11,11 +12,11 @@ class BaseExternalTool : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BaseExternalTool(BaseInstance *instance, QObject *parent = 0);
|
||||
explicit BaseExternalTool(InstancePtr instance, QObject *parent = 0);
|
||||
virtual ~BaseExternalTool();
|
||||
|
||||
protected:
|
||||
BaseInstance *m_instance;
|
||||
InstancePtr m_instance;
|
||||
|
||||
qint64 pid(QProcess *process);
|
||||
QString getSave() const;
|
||||
@ -25,7 +26,7 @@ class BaseDetachedTool : public BaseExternalTool
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BaseDetachedTool(BaseInstance *instance, QObject *parent = 0);
|
||||
explicit BaseDetachedTool(InstancePtr instance, QObject *parent = 0);
|
||||
|
||||
public
|
||||
slots:
|
||||
@ -44,7 +45,7 @@ public:
|
||||
|
||||
virtual void registerSettings(SettingsObject *settings) = 0;
|
||||
|
||||
virtual BaseExternalTool *createTool(BaseInstance *instance, QObject *parent = 0) = 0;
|
||||
virtual BaseExternalTool *createTool(InstancePtr instance, QObject *parent = 0) = 0;
|
||||
|
||||
virtual bool check(QString *error) = 0;
|
||||
virtual bool check(const QString &path, QString *error) = 0;
|
||||
@ -53,5 +54,5 @@ public:
|
||||
class BaseDetachedToolFactory : public BaseExternalToolFactory
|
||||
{
|
||||
public:
|
||||
virtual BaseDetachedTool *createDetachedTool(BaseInstance *instance, QObject *parent = 0);
|
||||
virtual BaseDetachedTool *createDetachedTool(InstancePtr instance, QObject *parent = 0);
|
||||
};
|
||||
|
@ -2,7 +2,7 @@
|
||||
|
||||
#include <QProcess>
|
||||
|
||||
BaseProfiler::BaseProfiler(BaseInstance *instance, QObject *parent)
|
||||
BaseProfiler::BaseProfiler(InstancePtr instance, QObject *parent)
|
||||
: BaseExternalTool(instance, parent)
|
||||
{
|
||||
}
|
||||
@ -29,7 +29,7 @@ void BaseProfiler::abortProfilingImpl()
|
||||
emit abortLaunch(tr("Profiler aborted"));
|
||||
}
|
||||
|
||||
BaseProfiler *BaseProfilerFactory::createProfiler(BaseInstance *instance, QObject *parent)
|
||||
BaseProfiler *BaseProfilerFactory::createProfiler(InstancePtr instance, QObject *parent)
|
||||
{
|
||||
return qobject_cast<BaseProfiler *>(createTool(instance, parent));
|
||||
}
|
||||
|
@ -11,7 +11,7 @@ class BaseProfiler : public BaseExternalTool
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit BaseProfiler(BaseInstance *instance, QObject *parent = 0);
|
||||
explicit BaseProfiler(InstancePtr instance, QObject *parent = 0);
|
||||
|
||||
public
|
||||
slots:
|
||||
@ -32,5 +32,5 @@ signals:
|
||||
class BaseProfilerFactory : public BaseExternalToolFactory
|
||||
{
|
||||
public:
|
||||
virtual BaseProfiler *createProfiler(BaseInstance *instance, QObject *parent = 0);
|
||||
virtual BaseProfiler *createProfiler(InstancePtr instance, QObject *parent = 0);
|
||||
};
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "logic/BaseInstance.h"
|
||||
#include "MultiMC.h"
|
||||
|
||||
JProfiler::JProfiler(BaseInstance *instance, QObject *parent) : BaseProfiler(instance, parent)
|
||||
JProfiler::JProfiler(InstancePtr instance, QObject *parent) : BaseProfiler(instance, parent)
|
||||
{
|
||||
}
|
||||
|
||||
@ -46,7 +46,7 @@ void JProfilerFactory::registerSettings(SettingsObject *settings)
|
||||
settings->registerSetting("JProfilerPort", 42042);
|
||||
}
|
||||
|
||||
BaseExternalTool *JProfilerFactory::createTool(BaseInstance *instance, QObject *parent)
|
||||
BaseExternalTool *JProfilerFactory::createTool(InstancePtr instance, QObject *parent)
|
||||
{
|
||||
return new JProfiler(instance, parent);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ class JProfiler : public BaseProfiler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
JProfiler(BaseInstance *instance, QObject *parent = 0);
|
||||
JProfiler(InstancePtr instance, QObject *parent = 0);
|
||||
|
||||
protected:
|
||||
void beginProfilingImpl(MinecraftProcess *process);
|
||||
@ -17,7 +17,7 @@ class JProfilerFactory : public BaseProfilerFactory
|
||||
public:
|
||||
QString name() const override { return "JProfiler"; }
|
||||
void registerSettings(SettingsObject *settings) override;
|
||||
BaseExternalTool *createTool(BaseInstance *instance, QObject *parent = 0) override;
|
||||
BaseExternalTool *createTool(InstancePtr instance, QObject *parent = 0) override;
|
||||
bool check(QString *error) override;
|
||||
bool check(const QString &path, QString *error) override;
|
||||
};
|
||||
|
@ -8,7 +8,7 @@
|
||||
#include "logic/BaseInstance.h"
|
||||
#include "MultiMC.h"
|
||||
|
||||
JVisualVM::JVisualVM(BaseInstance *instance, QObject *parent) : BaseProfiler(instance, parent)
|
||||
JVisualVM::JVisualVM(InstancePtr instance, QObject *parent) : BaseProfiler(instance, parent)
|
||||
{
|
||||
}
|
||||
|
||||
@ -47,7 +47,7 @@ void JVisualVMFactory::registerSettings(SettingsObject *settings)
|
||||
settings->registerSetting("JVisualVMPath", defaultValue);
|
||||
}
|
||||
|
||||
BaseExternalTool *JVisualVMFactory::createTool(BaseInstance *instance, QObject *parent)
|
||||
BaseExternalTool *JVisualVMFactory::createTool(InstancePtr instance, QObject *parent)
|
||||
{
|
||||
return new JVisualVM(instance, parent);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ class JVisualVM : public BaseProfiler
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
JVisualVM(BaseInstance *instance, QObject *parent = 0);
|
||||
JVisualVM(InstancePtr instance, QObject *parent = 0);
|
||||
|
||||
protected:
|
||||
void beginProfilingImpl(MinecraftProcess *process);
|
||||
@ -17,7 +17,7 @@ class JVisualVMFactory : public BaseProfilerFactory
|
||||
public:
|
||||
QString name() const override { return "JVisualVM"; }
|
||||
void registerSettings(SettingsObject *settings) override;
|
||||
BaseExternalTool *createTool(BaseInstance *instance, QObject *parent = 0) override;
|
||||
BaseExternalTool *createTool(InstancePtr instance, QObject *parent = 0) override;
|
||||
bool check(QString *error) override;
|
||||
bool check(const QString &path, QString *error) override;
|
||||
};
|
||||
|
@ -9,7 +9,7 @@
|
||||
#include "logic/BaseInstance.h"
|
||||
#include "MultiMC.h"
|
||||
|
||||
MCEditTool::MCEditTool(BaseInstance *instance, QObject *parent)
|
||||
MCEditTool::MCEditTool(InstancePtr instance, QObject *parent)
|
||||
: BaseDetachedTool(instance, parent)
|
||||
{
|
||||
}
|
||||
@ -47,7 +47,7 @@ void MCEditFactory::registerSettings(SettingsObject *settings)
|
||||
{
|
||||
settings->registerSetting("MCEditPath");
|
||||
}
|
||||
BaseExternalTool *MCEditFactory::createTool(BaseInstance *instance, QObject *parent)
|
||||
BaseExternalTool *MCEditFactory::createTool(InstancePtr instance, QObject *parent)
|
||||
{
|
||||
return new MCEditTool(instance, parent);
|
||||
}
|
||||
|
@ -6,7 +6,7 @@ class MCEditTool : public BaseDetachedTool
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit MCEditTool(BaseInstance *instance, QObject *parent = 0);
|
||||
explicit MCEditTool(InstancePtr instance, QObject *parent = 0);
|
||||
|
||||
protected:
|
||||
void runImpl() override;
|
||||
@ -17,7 +17,7 @@ class MCEditFactory : public BaseDetachedToolFactory
|
||||
public:
|
||||
QString name() const override { return "MCEdit"; }
|
||||
void registerSettings(SettingsObject *settings) override;
|
||||
BaseExternalTool *createTool(BaseInstance *instance, QObject *parent = 0) override;
|
||||
BaseExternalTool *createTool(InstancePtr instance, QObject *parent = 0) override;
|
||||
bool check(QString *error) override;
|
||||
bool check(const QString &path, QString *error) override;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user