summaryrefslogtreecommitdiffstats
path: root/application
diff options
context:
space:
mode:
authorPetr Mrázek <peterix@gmail.com>2015-09-30 22:52:55 +0200
committerPetr Mrázek <peterix@gmail.com>2015-09-30 22:52:55 +0200
commit477a1a88c6b7f5e5a78a2bbc4a6fe7781b2a0525 (patch)
tree8afd9d2359717b77c9c842b27598543af9069471 /application
parentcf0308c970aba7e282e4e98782187bc636f8ce26 (diff)
downloadMultiMC-477a1a88c6b7f5e5a78a2bbc4a6fe7781b2a0525.tar
MultiMC-477a1a88c6b7f5e5a78a2bbc4a6fe7781b2a0525.tar.gz
MultiMC-477a1a88c6b7f5e5a78a2bbc4a6fe7781b2a0525.tar.lz
MultiMC-477a1a88c6b7f5e5a78a2bbc4a6fe7781b2a0525.tar.xz
MultiMC-477a1a88c6b7f5e5a78a2bbc4a6fe7781b2a0525.zip
GH-1262 fix relative paths for java binaries
Diffstat (limited to 'application')
-rw-r--r--application/MainWindow.cpp13
-rw-r--r--application/pages/InstanceSettingsPage.cpp17
-rw-r--r--application/pages/global/JavaPage.cpp17
3 files changed, 30 insertions, 17 deletions
diff --git a/application/MainWindow.cpp b/application/MainWindow.cpp
index ecf0f371..1562efc5 100644
--- a/application/MainWindow.cpp
+++ b/application/MainWindow.cpp
@@ -1677,17 +1677,8 @@ void MainWindow::checkSetDefaultJava()
break;
}
QString currentJavaPath = MMC->settings()->get("JavaPath").toString();
- if (currentJavaPath.isEmpty())
- {
- askForJava = true;
- break;
- }
- if(!currentJavaPath.contains('/'))
- {
- currentJavaPath = QStandardPaths::findExecutable(currentJavaPath);
- }
- QFile currentJavaBin(currentJavaPath);
- if(!currentJavaBin.exists())
+ QString actualPath = ResolveExecutable(currentJavaPath);
+ if (currentJavaPath.isNull())
{
askForJava = true;
break;
diff --git a/application/pages/InstanceSettingsPage.cpp b/application/pages/InstanceSettingsPage.cpp
index 91b997d6..35cbefe5 100644
--- a/application/pages/InstanceSettingsPage.cpp
+++ b/application/pages/InstanceSettingsPage.cpp
@@ -10,6 +10,7 @@
#include "MultiMC.h"
#include <java/JavaVersionList.h>
+#include <pathutils.h>
InstanceSettingsPage::InstanceSettingsPage(BaseInstance *inst, QWidget *parent)
: QWidget(parent), ui(new Ui::InstanceSettingsPage), m_instance(inst)
@@ -184,11 +185,21 @@ void InstanceSettingsPage::on_javaDetectBtn_clicked()
void InstanceSettingsPage::on_javaBrowseBtn_clicked()
{
- QString dir = QFileDialog::getOpenFileName(this, tr("Find Java executable"));
- if (!dir.isNull())
+ QString raw_path = QFileDialog::getOpenFileName(this, tr("Find Java executable"));
+ QString cooked_path = NormalizePath(raw_path);
+
+ // do not allow current dir - it's dirty. Do not allow dirs that don't exist
+ if(cooked_path.isEmpty())
+ {
+ return;
+ }
+
+ QFileInfo javaInfo(cooked_path);;
+ if(!javaInfo.exists() || !javaInfo.isExecutable())
{
- ui->javaPathTextBox->setText(dir);
+ return;
}
+ ui->javaPathTextBox->setText(cooked_path);
}
void InstanceSettingsPage::on_javaTestBtn_clicked()
diff --git a/application/pages/global/JavaPage.cpp b/application/pages/global/JavaPage.cpp
index 9b35d1f3..18882ad9 100644
--- a/application/pages/global/JavaPage.cpp
+++ b/application/pages/global/JavaPage.cpp
@@ -105,13 +105,24 @@ void JavaPage::on_javaDetectBtn_clicked()
ui->javaPathTextBox->setText(java->path);
}
}
+
void JavaPage::on_javaBrowseBtn_clicked()
{
- QString dir = QFileDialog::getOpenFileName(this, tr("Find Java executable"));
- if (!dir.isNull())
+ QString raw_path = QFileDialog::getOpenFileName(this, tr("Find Java executable"));
+ QString cooked_path = NormalizePath(raw_path);
+
+ // do not allow current dir - it's dirty. Do not allow dirs that don't exist
+ if(cooked_path.isEmpty())
{
- ui->javaPathTextBox->setText(dir);
+ return;
+ }
+
+ QFileInfo javaInfo(cooked_path);;
+ if(!javaInfo.exists() || !javaInfo.isExecutable())
+ {
+ return;
}
+ ui->javaPathTextBox->setText(cooked_path);
}
void JavaPage::on_javaTestBtn_clicked()