NOISSUE use LoggedProcess to work around issues with QProcess on macOS
This commit is contained in:
parent
ac66af6c13
commit
f0b71f989e
@ -27,7 +27,7 @@
|
|||||||
#include "settings/INIFile.h"
|
#include "settings/INIFile.h"
|
||||||
#include "BaseVersionList.h"
|
#include "BaseVersionList.h"
|
||||||
#include "minecraft/auth/MojangAccount.h"
|
#include "minecraft/auth/MojangAccount.h"
|
||||||
#include "launch/MessageLevel.h"
|
#include "MessageLevel.h"
|
||||||
#include "pathmatcher/IPathMatcher.h"
|
#include "pathmatcher/IPathMatcher.h"
|
||||||
|
|
||||||
#include "multimc_logic_export.h"
|
#include "multimc_logic_export.h"
|
||||||
|
@ -16,6 +16,10 @@ set(CORE_SOURCES
|
|||||||
InstanceImportTask.cpp
|
InstanceImportTask.cpp
|
||||||
InstanceList.h
|
InstanceList.h
|
||||||
InstanceList.cpp
|
InstanceList.cpp
|
||||||
|
LoggedProcess.h
|
||||||
|
LoggedProcess.cpp
|
||||||
|
MessageLevel.cpp
|
||||||
|
MessageLevel.h
|
||||||
BaseInstanceProvider.h
|
BaseInstanceProvider.h
|
||||||
FolderInstanceProvider.h
|
FolderInstanceProvider.h
|
||||||
FolderInstanceProvider.cpp
|
FolderInstanceProvider.cpp
|
||||||
@ -126,12 +130,8 @@ set(LAUNCH_SOURCES
|
|||||||
launch/LaunchStep.h
|
launch/LaunchStep.h
|
||||||
launch/LaunchTask.cpp
|
launch/LaunchTask.cpp
|
||||||
launch/LaunchTask.h
|
launch/LaunchTask.h
|
||||||
launch/LoggedProcess.cpp
|
|
||||||
launch/LoggedProcess.h
|
|
||||||
launch/LogModel.cpp
|
launch/LogModel.cpp
|
||||||
launch/LogModel.h
|
launch/LogModel.h
|
||||||
launch/MessageLevel.cpp
|
|
||||||
launch/MessageLevel.h
|
|
||||||
)
|
)
|
||||||
|
|
||||||
# Old update system
|
# Old update system
|
||||||
|
@ -17,12 +17,13 @@
|
|||||||
|
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
#include "MessageLevel.h"
|
#include "MessageLevel.h"
|
||||||
|
#include "multimc_logic_export.h"
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* This is a basic process.
|
* This is a basic process.
|
||||||
* It has line-based logging support and hides some of the nasty bits.
|
* 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
|
Q_OBJECT
|
||||||
public:
|
public:
|
@ -16,7 +16,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <launch/LaunchStep.h>
|
#include <launch/LaunchStep.h>
|
||||||
#include <launch/LoggedProcess.h>
|
#include <LoggedProcess.h>
|
||||||
#include <java/JavaChecker.h>
|
#include <java/JavaChecker.h>
|
||||||
|
|
||||||
class CheckJava: public LaunchStep
|
class CheckJava: public LaunchStep
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <launch/LaunchStep.h>
|
#include <launch/LaunchStep.h>
|
||||||
#include <launch/LoggedProcess.h>
|
#include <LoggedProcess.h>
|
||||||
|
|
||||||
class PostLaunchCommand: public LaunchStep
|
class PostLaunchCommand: public LaunchStep
|
||||||
{
|
{
|
||||||
|
@ -15,8 +15,8 @@
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <launch/LaunchStep.h>
|
#include "launch/LaunchStep.h"
|
||||||
#include <launch/LoggedProcess.h>
|
#include "LoggedProcess.h"
|
||||||
|
|
||||||
class PreLaunchCommand: public LaunchStep
|
class PreLaunchCommand: public LaunchStep
|
||||||
{
|
{
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <launch/LaunchStep.h>
|
#include <launch/LaunchStep.h>
|
||||||
#include <launch/LoggedProcess.h>
|
#include <LoggedProcess.h>
|
||||||
#include <java/JavaChecker.h>
|
#include <java/JavaChecker.h>
|
||||||
|
|
||||||
#include "multimc_logic_export.h"
|
#include "multimc_logic_export.h"
|
||||||
|
@ -17,7 +17,7 @@
|
|||||||
|
|
||||||
#include <launch/LaunchStep.h>
|
#include <launch/LaunchStep.h>
|
||||||
#include <QObjectPtr.h>
|
#include <QObjectPtr.h>
|
||||||
#include <launch/LoggedProcess.h>
|
#include <LoggedProcess.h>
|
||||||
#include <java/JavaChecker.h>
|
#include <java/JavaChecker.h>
|
||||||
|
|
||||||
// FIXME: stupid. should be defined by the instance type? or even completely abstracted away...
|
// FIXME: stupid. should be defined by the instance type? or even completely abstracted away...
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <launch/LaunchStep.h>
|
#include <launch/LaunchStep.h>
|
||||||
#include <launch/LoggedProcess.h>
|
#include <LoggedProcess.h>
|
||||||
#include <minecraft/auth/AuthSession.h>
|
#include <minecraft/auth/AuthSession.h>
|
||||||
|
|
||||||
// HACK: this is a workaround for MCL-3732 - 'server-resource-packs' folder is created.
|
// HACK: this is a workaround for MCL-3732 - 'server-resource-packs' folder is created.
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <launch/LaunchStep.h>
|
#include <launch/LaunchStep.h>
|
||||||
#include <launch/LoggedProcess.h>
|
#include <LoggedProcess.h>
|
||||||
#include <minecraft/auth/AuthSession.h>
|
#include <minecraft/auth/AuthSession.h>
|
||||||
|
|
||||||
class DirectJavaLaunch: public LaunchStep
|
class DirectJavaLaunch: public LaunchStep
|
||||||
|
@ -16,7 +16,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
|
|
||||||
#include <launch/LaunchStep.h>
|
#include <launch/LaunchStep.h>
|
||||||
#include <launch/LoggedProcess.h>
|
#include <LoggedProcess.h>
|
||||||
#include <minecraft/auth/AuthSession.h>
|
#include <minecraft/auth/AuthSession.h>
|
||||||
|
|
||||||
class LauncherPartLaunch: public LaunchStep
|
class LauncherPartLaunch: public LaunchStep
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
#pragma once
|
#pragma once
|
||||||
#include <QtGui/QColor>
|
#include <QtGui/QColor>
|
||||||
#include <rainbow.h>
|
#include <rainbow.h>
|
||||||
#include <launch/MessageLevel.h>
|
#include <MessageLevel.h>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
|
||||||
class ColorCache
|
class ColorCache
|
||||||
|
@ -29,6 +29,7 @@
|
|||||||
#include "MultiMC.h"
|
#include "MultiMC.h"
|
||||||
#include <GuiUtil.h>
|
#include <GuiUtil.h>
|
||||||
#include <QProcess>
|
#include <QProcess>
|
||||||
|
#include <FileSystem.h>
|
||||||
|
|
||||||
WorldListPage::WorldListPage(BaseInstance *inst, std::shared_ptr<WorldList> worlds, QString id,
|
WorldListPage::WorldListPage(BaseInstance *inst, std::shared_ptr<WorldList> worlds, QString id,
|
||||||
QString iconName, QString displayName, QString helpPage,
|
QString iconName, QString displayName, QString helpPage,
|
||||||
@ -149,7 +150,11 @@ void WorldListPage::on_copySeedBtn_clicked()
|
|||||||
|
|
||||||
void WorldListPage::on_mcEditBtn_clicked()
|
void WorldListPage::on_mcEditBtn_clicked()
|
||||||
{
|
{
|
||||||
|
if(m_mceditStarting)
|
||||||
|
return;
|
||||||
|
|
||||||
auto mcedit = MMC->mcedit();
|
auto mcedit = MMC->mcedit();
|
||||||
|
|
||||||
const QString mceditPath = mcedit->path();
|
const QString mceditPath = mcedit->path();
|
||||||
|
|
||||||
QModelIndex index = getSelectedWorld();
|
QModelIndex index = getSelectedWorld();
|
||||||
@ -167,15 +172,11 @@ void WorldListPage::on_mcEditBtn_clicked()
|
|||||||
auto program = mcedit->getProgramPath();
|
auto program = mcedit->getProgramPath();
|
||||||
if(program.size())
|
if(program.size())
|
||||||
{
|
{
|
||||||
qint64 pid;
|
m_mceditProcess.reset(new LoggedProcess());
|
||||||
if(!QProcess::startDetached(program, QStringList() << fullPath, mceditPath, &pid))
|
m_mceditProcess->setDetachable(true);
|
||||||
{
|
connect(m_mceditProcess.get(), &LoggedProcess::stateChanged, this, &WorldListPage::mceditState);
|
||||||
QMessageBox::warning(
|
m_mceditProcess->start(program, {fullPath});
|
||||||
this->parentWidget(),
|
m_mceditStarting = true;
|
||||||
tr("MCEdit failed to start!"),
|
|
||||||
tr("MCEdit failed to start.\nIt may be necessary to reinstall it.")
|
|
||||||
);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else
|
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)
|
void WorldListPage::worldChanged(const QModelIndex ¤t, const QModelIndex &previous)
|
||||||
{
|
{
|
||||||
QModelIndex index = getSelectedWorld();
|
QModelIndex index = getSelectedWorld();
|
||||||
|
@ -20,6 +20,7 @@
|
|||||||
#include "minecraft/onesix/OneSixInstance.h"
|
#include "minecraft/onesix/OneSixInstance.h"
|
||||||
#include "BasePage.h"
|
#include "BasePage.h"
|
||||||
#include <MultiMC.h>
|
#include <MultiMC.h>
|
||||||
|
#include <LoggedProcess.h>
|
||||||
|
|
||||||
class WorldList;
|
class WorldList;
|
||||||
namespace Ui
|
namespace Ui
|
||||||
@ -73,6 +74,8 @@ private:
|
|||||||
private:
|
private:
|
||||||
Ui::WorldListPage *ui;
|
Ui::WorldListPage *ui;
|
||||||
std::shared_ptr<WorldList> m_worlds;
|
std::shared_ptr<WorldList> m_worlds;
|
||||||
|
unique_qobject_ptr<LoggedProcess> m_mceditProcess;
|
||||||
|
bool m_mceditStarting = false;
|
||||||
QString m_iconName;
|
QString m_iconName;
|
||||||
QString m_id;
|
QString m_id;
|
||||||
QString m_displayName;
|
QString m_displayName;
|
||||||
@ -88,4 +91,5 @@ private slots:
|
|||||||
void on_refreshBtn_clicked();
|
void on_refreshBtn_clicked();
|
||||||
void on_viewFolderBtn_clicked();
|
void on_viewFolderBtn_clicked();
|
||||||
void worldChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
void worldChanged(const QModelIndex ¤t, const QModelIndex &previous);
|
||||||
|
void mceditState(LoggedProcess::State state);
|
||||||
};
|
};
|
||||||
|
Loading…
Reference in New Issue
Block a user