summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2016-11-03 01:10:16 +0100
committerPetr Mrázek <peterix@gmail.com>2016-11-03 01:11:57 +0100
commitf0b71f989ea798495ad80d1f059ae0a28514f9a2 (patch)
tree8551131b5ce3ccaa3c422f6635aefdbf6ca149ff /application
parentac66af6c13604a4eb2d36cc82417aa6753b84afe (diff)
downloadMultiMC-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
Diffstat (limited to 'application')
-rw-r--r--application/ColorCache.h2
-rw-r--r--application/pages/WorldListPage.cpp50
-rw-r--r--application/pages/WorldListPage.h4
3 files changed, 46 insertions, 10 deletions
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 &current, 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 &current, const QModelIndex &previous);
+ void mceditState(LoggedProcess::State state);
};