diff options
author | Petr Mrázek <peterix@gmail.com> | 2016-11-03 01:10:16 +0100 |
---|---|---|
committer | Petr Mrázek <peterix@gmail.com> | 2016-11-03 01:11:57 +0100 |
commit | f0b71f989ea798495ad80d1f059ae0a28514f9a2 (patch) | |
tree | 8551131b5ce3ccaa3c422f6635aefdbf6ca149ff | |
parent | ac66af6c13604a4eb2d36cc82417aa6753b84afe (diff) | |
download | MultiMC-f0b71f989ea798495ad80d1f059ae0a28514f9a2.tar MultiMC-f0b71f989ea798495ad80d1f059ae0a28514f9a2.tar.gz MultiMC-f0b71f989ea798495ad80d1f059ae0a28514f9a2.tar.lz MultiMC-f0b71f989ea798495ad80d1f059ae0a28514f9a2.tar.xz MultiMC-f0b71f989ea798495ad80d1f059ae0a28514f9a2.zip |
NOISSUE use LoggedProcess to work around issues with QProcess on macOS
-rw-r--r-- | api/logic/BaseInstance.h | 2 | ||||
-rw-r--r-- | api/logic/CMakeLists.txt | 8 | ||||
-rw-r--r-- | api/logic/LoggedProcess.cpp (renamed from api/logic/launch/LoggedProcess.cpp) | 0 | ||||
-rw-r--r-- | api/logic/LoggedProcess.h (renamed from api/logic/launch/LoggedProcess.h) | 3 | ||||
-rw-r--r-- | api/logic/MessageLevel.cpp (renamed from api/logic/launch/MessageLevel.cpp) | 0 | ||||
-rw-r--r-- | api/logic/MessageLevel.h (renamed from api/logic/launch/MessageLevel.h) | 0 | ||||
-rw-r--r-- | api/logic/java/launch/CheckJava.h | 2 | ||||
-rw-r--r-- | api/logic/launch/steps/PostLaunchCommand.h | 2 | ||||
-rw-r--r-- | api/logic/launch/steps/PreLaunchCommand.h | 4 | ||||
-rw-r--r-- | api/logic/launch/steps/TextPrint.h | 2 | ||||
-rw-r--r-- | api/logic/launch/steps/Update.h | 2 | ||||
-rw-r--r-- | api/logic/minecraft/launch/CreateServerResourcePacksFolder.h | 2 | ||||
-rw-r--r-- | api/logic/minecraft/launch/DirectJavaLaunch.h | 2 | ||||
-rw-r--r-- | api/logic/minecraft/launch/LauncherPartLaunch.h | 2 | ||||
-rw-r--r-- | application/ColorCache.h | 2 | ||||
-rw-r--r-- | application/pages/WorldListPage.cpp | 50 | ||||
-rw-r--r-- | application/pages/WorldListPage.h | 4 |
17 files changed, 62 insertions, 25 deletions
diff --git a/api/logic/BaseInstance.h b/api/logic/BaseInstance.h index 56d3d6cb..669bad79 100644 --- a/api/logic/BaseInstance.h +++ b/api/logic/BaseInstance.h @@ -27,7 +27,7 @@ #include "settings/INIFile.h" #include "BaseVersionList.h" #include "minecraft/auth/MojangAccount.h" -#include "launch/MessageLevel.h" +#include "MessageLevel.h" #include "pathmatcher/IPathMatcher.h" #include "multimc_logic_export.h" diff --git a/api/logic/CMakeLists.txt b/api/logic/CMakeLists.txt index 0741fb1a..6d0f78f9 100644 --- a/api/logic/CMakeLists.txt +++ b/api/logic/CMakeLists.txt @@ -16,6 +16,10 @@ set(CORE_SOURCES InstanceImportTask.cpp InstanceList.h InstanceList.cpp + LoggedProcess.h + LoggedProcess.cpp + MessageLevel.cpp + MessageLevel.h BaseInstanceProvider.h FolderInstanceProvider.h FolderInstanceProvider.cpp @@ -126,12 +130,8 @@ set(LAUNCH_SOURCES launch/LaunchStep.h launch/LaunchTask.cpp launch/LaunchTask.h - launch/LoggedProcess.cpp - launch/LoggedProcess.h launch/LogModel.cpp launch/LogModel.h - launch/MessageLevel.cpp - launch/MessageLevel.h ) # Old update system diff --git a/api/logic/launch/LoggedProcess.cpp b/api/logic/LoggedProcess.cpp index f89b4acc..f89b4acc 100644 --- a/api/logic/launch/LoggedProcess.cpp +++ b/api/logic/LoggedProcess.cpp diff --git a/api/logic/launch/LoggedProcess.h b/api/logic/LoggedProcess.h index c4e5c52c..e1928689 100644 --- a/api/logic/launch/LoggedProcess.h +++ b/api/logic/LoggedProcess.h @@ -17,12 +17,13 @@ #include <QProcess> #include "MessageLevel.h" +#include "multimc_logic_export.h" /* * This is a basic process. * It has line-based logging support and hides some of the nasty bits. */ -class LoggedProcess : public QProcess +class MULTIMC_LOGIC_EXPORT LoggedProcess : public QProcess { Q_OBJECT public: diff --git a/api/logic/launch/MessageLevel.cpp b/api/logic/MessageLevel.cpp index a5191290..a5191290 100644 --- a/api/logic/launch/MessageLevel.cpp +++ b/api/logic/MessageLevel.cpp diff --git a/api/logic/launch/MessageLevel.h b/api/logic/MessageLevel.h index 0128148d..0128148d 100644 --- a/api/logic/launch/MessageLevel.h +++ b/api/logic/MessageLevel.h diff --git a/api/logic/java/launch/CheckJava.h b/api/logic/java/launch/CheckJava.h index 118da225..7126f4c4 100644 --- a/api/logic/java/launch/CheckJava.h +++ b/api/logic/java/launch/CheckJava.h @@ -16,7 +16,7 @@ #pragma once #include <launch/LaunchStep.h> -#include <launch/LoggedProcess.h> +#include <LoggedProcess.h> #include <java/JavaChecker.h> class CheckJava: public LaunchStep diff --git a/api/logic/launch/steps/PostLaunchCommand.h b/api/logic/launch/steps/PostLaunchCommand.h index 4d5b0a52..2b68ee86 100644 --- a/api/logic/launch/steps/PostLaunchCommand.h +++ b/api/logic/launch/steps/PostLaunchCommand.h @@ -16,7 +16,7 @@ #pragma once #include <launch/LaunchStep.h> -#include <launch/LoggedProcess.h> +#include <LoggedProcess.h> class PostLaunchCommand: public LaunchStep { diff --git a/api/logic/launch/steps/PreLaunchCommand.h b/api/logic/launch/steps/PreLaunchCommand.h index 077bdfca..eb7bc0b6 100644 --- a/api/logic/launch/steps/PreLaunchCommand.h +++ b/api/logic/launch/steps/PreLaunchCommand.h @@ -15,8 +15,8 @@ #pragma once -#include <launch/LaunchStep.h> -#include <launch/LoggedProcess.h> +#include "launch/LaunchStep.h" +#include "LoggedProcess.h" class PreLaunchCommand: public LaunchStep { diff --git a/api/logic/launch/steps/TextPrint.h b/api/logic/launch/steps/TextPrint.h index fdd9014a..5b82aff8 100644 --- a/api/logic/launch/steps/TextPrint.h +++ b/api/logic/launch/steps/TextPrint.h @@ -16,7 +16,7 @@ #pragma once #include <launch/LaunchStep.h> -#include <launch/LoggedProcess.h> +#include <LoggedProcess.h> #include <java/JavaChecker.h> #include "multimc_logic_export.h" diff --git a/api/logic/launch/steps/Update.h b/api/logic/launch/steps/Update.h index 1739de47..ad7cfa69 100644 --- a/api/logic/launch/steps/Update.h +++ b/api/logic/launch/steps/Update.h @@ -17,7 +17,7 @@ #include <launch/LaunchStep.h> #include <QObjectPtr.h> -#include <launch/LoggedProcess.h> +#include <LoggedProcess.h> #include <java/JavaChecker.h> // FIXME: stupid. should be defined by the instance type? or even completely abstracted away... diff --git a/api/logic/minecraft/launch/CreateServerResourcePacksFolder.h b/api/logic/minecraft/launch/CreateServerResourcePacksFolder.h index d35ccc69..46a3a974 100644 --- a/api/logic/minecraft/launch/CreateServerResourcePacksFolder.h +++ b/api/logic/minecraft/launch/CreateServerResourcePacksFolder.h @@ -16,7 +16,7 @@ #pragma once #include <launch/LaunchStep.h> -#include <launch/LoggedProcess.h> +#include <LoggedProcess.h> #include <minecraft/auth/AuthSession.h> // HACK: this is a workaround for MCL-3732 - 'server-resource-packs' folder is created. diff --git a/api/logic/minecraft/launch/DirectJavaLaunch.h b/api/logic/minecraft/launch/DirectJavaLaunch.h index 0e3d66cc..eff13f16 100644 --- a/api/logic/minecraft/launch/DirectJavaLaunch.h +++ b/api/logic/minecraft/launch/DirectJavaLaunch.h @@ -16,7 +16,7 @@ #pragma once #include <launch/LaunchStep.h> -#include <launch/LoggedProcess.h> +#include <LoggedProcess.h> #include <minecraft/auth/AuthSession.h> class DirectJavaLaunch: public LaunchStep diff --git a/api/logic/minecraft/launch/LauncherPartLaunch.h b/api/logic/minecraft/launch/LauncherPartLaunch.h index 209902e0..dfa08f7a 100644 --- a/api/logic/minecraft/launch/LauncherPartLaunch.h +++ b/api/logic/minecraft/launch/LauncherPartLaunch.h @@ -16,7 +16,7 @@ #pragma once #include <launch/LaunchStep.h> -#include <launch/LoggedProcess.h> +#include <LoggedProcess.h> #include <minecraft/auth/AuthSession.h> class LauncherPartLaunch: public LaunchStep diff --git a/application/ColorCache.h b/application/ColorCache.h index 9d5ad02b..1ce1c211 100644 --- a/application/ColorCache.h +++ b/application/ColorCache.h @@ -1,7 +1,7 @@ #pragma once #include <QtGui/QColor> #include <rainbow.h> -#include <launch/MessageLevel.h> +#include <MessageLevel.h> #include <QMap> class ColorCache diff --git a/application/pages/WorldListPage.cpp b/application/pages/WorldListPage.cpp index a4f17744..365da4a4 100644 --- a/application/pages/WorldListPage.cpp +++ b/application/pages/WorldListPage.cpp @@ -29,6 +29,7 @@ #include "MultiMC.h" #include <GuiUtil.h> #include <QProcess> +#include <FileSystem.h> WorldListPage::WorldListPage(BaseInstance *inst, std::shared_ptr<WorldList> worlds, QString id, QString iconName, QString displayName, QString helpPage, @@ -149,7 +150,11 @@ void WorldListPage::on_copySeedBtn_clicked() void WorldListPage::on_mcEditBtn_clicked() { + if(m_mceditStarting) + return; + auto mcedit = MMC->mcedit(); + const QString mceditPath = mcedit->path(); QModelIndex index = getSelectedWorld(); @@ -167,15 +172,11 @@ void WorldListPage::on_mcEditBtn_clicked() auto program = mcedit->getProgramPath(); if(program.size()) { - qint64 pid; - if(!QProcess::startDetached(program, QStringList() << fullPath, mceditPath, &pid)) - { - QMessageBox::warning( - this->parentWidget(), - tr("MCEdit failed to start!"), - tr("MCEdit failed to start.\nIt may be necessary to reinstall it.") - ); - } + m_mceditProcess.reset(new LoggedProcess()); + m_mceditProcess->setDetachable(true); + connect(m_mceditProcess.get(), &LoggedProcess::stateChanged, this, &WorldListPage::mceditState); + m_mceditProcess->start(program, {fullPath}); + m_mceditStarting = true; } else { @@ -187,6 +188,37 @@ void WorldListPage::on_mcEditBtn_clicked() } } +void WorldListPage::mceditState(LoggedProcess::State state) +{ + bool failed = false; + switch(state) + { + case LoggedProcess::NotRunning: + case LoggedProcess::Starting: + return; + case LoggedProcess::FailedToStart: + case LoggedProcess::Crashed: + case LoggedProcess::Aborted: + { + failed = true; + } + case LoggedProcess::Running: + case LoggedProcess::Finished: + { + m_mceditStarting = false; + break; + } + } + if(failed) + { + QMessageBox::warning( + this->parentWidget(), + tr("MCEdit failed to start!"), + tr("MCEdit failed to start.\nIt may be necessary to reinstall it.") + ); + } +} + void WorldListPage::worldChanged(const QModelIndex ¤t, const QModelIndex &previous) { QModelIndex index = getSelectedWorld(); diff --git a/application/pages/WorldListPage.h b/application/pages/WorldListPage.h index 8a9fc16f..0a09764e 100644 --- a/application/pages/WorldListPage.h +++ b/application/pages/WorldListPage.h @@ -20,6 +20,7 @@ #include "minecraft/onesix/OneSixInstance.h" #include "BasePage.h" #include <MultiMC.h> +#include <LoggedProcess.h> class WorldList; namespace Ui @@ -73,6 +74,8 @@ private: private: Ui::WorldListPage *ui; std::shared_ptr<WorldList> m_worlds; + unique_qobject_ptr<LoggedProcess> m_mceditProcess; + bool m_mceditStarting = false; QString m_iconName; QString m_id; QString m_displayName; @@ -88,4 +91,5 @@ private slots: void on_refreshBtn_clicked(); void on_viewFolderBtn_clicked(); void worldChanged(const QModelIndex ¤t, const QModelIndex &previous); + void mceditState(LoggedProcess::State state); }; |