[X2Go-Commits] [x2goclient] 02/02: src/onmainwindow.cpp: replace old code to modify the PATH value with the new add_to_path () function.

git-admin at x2go.org git-admin at x2go.org
Sat Apr 9 08:39:33 CEST 2016


This is an automated email from the git hooks/post-receive script.

x2go pushed a commit to branch master
in repository x2goclient.

commit 2ace014ccfdb7a16a956d4f1bb98b6eb8a284b8d
Author: Mihai Moldovan <ionic at ionic.de>
Date:   Sat Apr 9 08:38:30 2016 +0200

    src/onmainwindow.cpp: replace old code to modify the PATH value with the new add_to_path () function.
---
 debian/changelog     |    2 ++
 src/onmainwindow.cpp |   44 ++++++--------------------------------------
 2 files changed, 8 insertions(+), 38 deletions(-)

diff --git a/debian/changelog b/debian/changelog
index 6b16560..80d3c80 100644
--- a/debian/changelog
+++ b/debian/changelog
@@ -20,6 +20,8 @@ x2goclient (4.0.5.2-0x2go1) UNRELEASED; urgency=medium
       OS X.
     - src/x2goutils.{cpp,h}: add new function add_to_path () to add multiple
       entries to a PATH-like string if they do not exist in there yet.
+    - src/onmainwindow.cpp: replace old code to modify the PATH value with the
+      new add_to_path () function.
 
   [ Mike DePaulo ]
   * New upstream release (4.0.5.2):
diff --git a/src/onmainwindow.cpp b/src/onmainwindow.cpp
index 4a48157..c7fffd7 100644
--- a/src/onmainwindow.cpp
+++ b/src/onmainwindow.cpp
@@ -5624,45 +5624,13 @@ void ONMainWindow::slotSetModMap()
             tmp_env.insert ("PATH", path_val);
         }
         else {
-            /* FIXME: split/clean this up. */
-            /* Search for and add /opt/X11/bin if necessary. */
-            QStringList tmp_path = path_val.split (":");
-            bool xquartz_found = false,
-                 macports_found = false,
-                 local_found = false;
-            for (int i = 0; i < tmp_path.length (); ++i) {
-                if ((tmp_path[i] == QString ("/opt/X11/bin")) || (tmp_path[i] == QString ("/opt/X11/bin/"))) {
-                    xquartz_found = true;
-                    continue;
-                }
-
-                if ((tmp_path[i] == QString ("/opt/local/bin")) || (tmp_path[i] == QString ("/opt/local/bin/"))) {
-                    macports_found = true;
-                    continue;
-                }
-
+            /* Search for and add specific directories to the PATH value, if necessary. */
+            QStringList to_back, to_front;
+            to_back << "/opt/X11/bin";
+            to_front << "/opt/local/bin" << "/usr/local/bin";
 
-                if ((tmp_path[i] == QString ("/usr/local/bin")) || (tmp_path[i] == QString ("/usr/local/bin/"))) {
-                    local_found = true;
-                    continue;
-                }
-
-                if (xquartz_found && macports_found && local_found) {
-                    break;
-                }
-            }
-
-            if (!xquartz_found) {
-                path_val.append (":/opt/X11/bin");
-            }
-
-            if (!local_found) {
-                path_val.prepend ("/usr/local/bin:");
-            }
-
-            if (!macports_found) {
-                path_val.prepend ("/opt/local/bin:");
-            }
+            path_val = add_to_path (path_val, to_back);
+            path_val = add_to_path (path_val, to_front, false);
 
             /* Insert will overwrite the value automatically. */
             tmp_env.insert ("PATH", path_val);

--
Alioth's /srv/git/code.x2go.org/x2goclient.git//..//_hooks_/post-receive-email on /srv/git/code.x2go.org/x2goclient.git


More information about the x2go-commits mailing list