[gnome-builder] project-tree: avoid using g_setenv()



commit f10a0592978ef087bb33d29ba419d5133f3446b0
Author: Christian Hergert <chergert redhat com>
Date:   Sat Feb 18 11:37:53 2017 -0800

    project-tree: avoid using g_setenv()
    
    There are race conditions inherently in use of setenv()/getenv() after
    initialization due to thread creation. Instead, since we are in control
    of the environ, just set SHELL in our environ array.

 plugins/project-tree/gb-project-tree-actions.c |   11 ++++-------
 1 files changed, 4 insertions(+), 7 deletions(-)
---
diff --git a/plugins/project-tree/gb-project-tree-actions.c b/plugins/project-tree/gb-project-tree-actions.c
index e21ff91..542b5e6 100644
--- a/plugins/project-tree/gb-project-tree-actions.c
+++ b/plugins/project-tree/gb-project-tree-actions.c
@@ -330,22 +330,19 @@ gb_project_tree_actions_open_in_terminal (GSimpleAction *action,
   argv[0] = terminal_executable;
   g_return_if_fail (terminal_executable != NULL);
 
+  env = g_get_environ ();
+
 #ifdef HAVE_VTE
   {
     /*
      * Overwrite SHELL to the users default shell.
      * Failure to do so typically results in /bin/sh being used.
      */
-    gchar *shell;
-
-    shell = vte_get_user_shell ();
-    g_setenv ("SHELL", shell, TRUE);
-    g_free (shell);
+    g_autofree gchar *shell = vte_get_user_shell ();
+    env = g_environ_setenv (env, "SHELL", shell, TRUE);
   }
 #endif
 
-  env = g_get_environ ();
-
   /* Can't use GdkAppLaunchContext as
    * we cannot set the working directory.
    */


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]