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