From 6ebf6e7785da79f7f3eb28176951d0e9d22a20e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Petr=20Mr=C3=A1zek?= Date: Thu, 3 Nov 2016 02:41:01 +0100 Subject: NOISSUE ifdef the hell out of MCEdit launch on Windows Setting the work directory was not enough. --- application/pages/WorldListPage.cpp | 22 +++++++++++++++++----- application/pages/WorldListPage.h | 1 + 2 files changed, 18 insertions(+), 5 deletions(-) (limited to 'application') diff --git a/application/pages/WorldListPage.cpp b/application/pages/WorldListPage.cpp index cc712572..4666b1ef 100644 --- a/application/pages/WorldListPage.cpp +++ b/application/pages/WorldListPage.cpp @@ -172,12 +172,19 @@ void WorldListPage::on_mcEditBtn_clicked() auto program = mcedit->getProgramPath(); if(program.size()) { +#ifdef Q_OS_WIN32 + if(!QProcess::startDetached(program, {fullPath}, mceditPath)) + { + mceditError(); + } +#else m_mceditProcess.reset(new LoggedProcess()); m_mceditProcess->setDetachable(true); connect(m_mceditProcess.get(), &LoggedProcess::stateChanged, this, &WorldListPage::mceditState); m_mceditProcess->start(program, {fullPath}); m_mceditProcess->setWorkingDirectory(mceditPath); m_mceditStarting = true; +#endif } else { @@ -189,6 +196,15 @@ void WorldListPage::on_mcEditBtn_clicked() } } +void WorldListPage::mceditError() +{ + QMessageBox::warning( + this->parentWidget(), + tr("MCEdit failed to start!"), + tr("MCEdit failed to start.\nIt may be necessary to reinstall it.") + ); +} + void WorldListPage::mceditState(LoggedProcess::State state) { bool failed = false; @@ -212,11 +228,7 @@ void WorldListPage::mceditState(LoggedProcess::State state) } if(failed) { - QMessageBox::warning( - this->parentWidget(), - tr("MCEdit failed to start!"), - tr("MCEdit failed to start.\nIt may be necessary to reinstall it.") - ); + mceditError(); } } diff --git a/application/pages/WorldListPage.h b/application/pages/WorldListPage.h index 0a09764e..5e7432e2 100644 --- a/application/pages/WorldListPage.h +++ b/application/pages/WorldListPage.h @@ -70,6 +70,7 @@ private: QModelIndex getSelectedWorld(); bool isWorldSafe(QModelIndex index); bool worldSafetyNagQuestion(); + void mceditError(); private: Ui::WorldListPage *ui; -- cgit v1.2.3