diff src/settingsdialog.cpp @ 465:b57d50114d8d

Look up diff/merge paths again if current settings are found not to exist (fixes #111)
author Chris Cannam
date Mon, 04 Jul 2011 14:03:31 +0100
parents c567fed39559
children 46ef2f03273c
line wrap: on
line diff
--- a/src/settingsdialog.cpp	Mon Jul 04 13:48:04 2011 +0100
+++ b/src/settingsdialog.cpp	Mon Jul 04 14:03:31 2011 +0100
@@ -297,25 +297,26 @@
     QSettings settings;
     settings.beginGroup("Locations");
     QString diff = settings.value("extdiffbinary", "").toString();
-    if (diff == "") {
-        QStringList bases;
+    if (diff != "" && QFile(diff).exists()) {
+        return;
+    }
+    QStringList bases;
 #ifdef Q_OS_WIN32
-        bases << "easyhg-extdiff.bat";
+    bases << "easyhg-extdiff.bat";
 #else
-        bases << "easyhg-extdiff.sh";
+    bases << "easyhg-extdiff.sh";
 #endif
-        bases << "kompare" << "kdiff3" << "meld";
-        bool found = false;
-        foreach (QString base, bases) {
-            diff = findInPath(base, m_installPath, true);
-            if (diff != "") {
-                found = true;
-                break;
-            }
+    bases << "kompare" << "kdiff3" << "meld";
+    bool found = false;
+    foreach (QString base, bases) {
+        diff = findInPath(base, m_installPath, true);
+        if (diff != "") {
+            found = true;
+            break;
         }
-        if (found) {
-            settings.setValue("extdiffbinary", diff);
-        }
+    }
+    if (found) {
+        settings.setValue("extdiffbinary", diff);
     }
 }
 
@@ -324,10 +325,10 @@
 {
     QSettings settings;
     settings.beginGroup("Locations");
-    if (settings.contains("mergebinary")) {
+    QString merge = settings.value("mergebinary", "").toString();
+    if (merge != "" && QFile(merge).exists()) {
         return;
     }
-    QString merge;
     QStringList bases;
 #ifdef Q_OS_WIN32
     bases << "easyhg-merge.bat";
@@ -355,10 +356,10 @@
 {
     QSettings settings;
     settings.beginGroup("Locations");
-    if (settings.contains("sshbinary")) {
+    QString ssh = settings.value("sshbinary", "").toString();
+    if (ssh != "" && QFile(ssh).exists()) {
         return;
     }
-    QString ssh;
     QStringList bases;
 #ifdef Q_OS_WIN32
     bases << "TortoisePlink.exe";
@@ -384,30 +385,31 @@
     QSettings settings;
     settings.beginGroup("Locations");
     QString editor = settings.value("editorbinary", "").toString();
-    if (editor == "") {
-        QStringList bases;
-        bases
+    if (editor != "" && QFile(editor).exists()) {
+        return;
+    }
+    QStringList bases;
+    bases
 #if defined Q_OS_WIN32
-            << "wordpad.exe"
-            << "C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe"
-            << "notepad.exe"
+        << "wordpad.exe"
+        << "C:\\Program Files\\Windows NT\\Accessories\\wordpad.exe"
+        << "notepad.exe"
 #elif defined Q_OS_MAC
-            << "/Applications/TextEdit.app/Contents/MacOS/TextEdit"
+        << "/Applications/TextEdit.app/Contents/MacOS/TextEdit"
 #else
-            << "gedit" << "kate"
+        << "gedit" << "kate"
 #endif
-            ;
-        bool found = false;
-        foreach (QString base, bases) {
-            editor = findInPath(base, m_installPath, true);
-            if (editor != "") {
-                found = true;
-                break;
-            }
+        ;
+    bool found = false;
+    foreach (QString base, bases) {
+        editor = findInPath(base, m_installPath, true);
+        if (editor != "") {
+            found = true;
+            break;
         }
-        if (found) {
-            settings.setValue("editorbinary", editor);
-        }
+    }
+    if (found) {
+        settings.setValue("editorbinary", editor);
     }
 }