[meld/meld-3-20: 1/2] win32: workaround startup error with MSYSTEM env



commit 23f84ea9959202a728e172246182b5dff187b74e
Author: Vasily Galkin <galkin-vv ya ru>
Date:   Sun Jan 5 03:10:11 2020 +0300

    win32: workaround startup error with MSYSTEM env
    
    Dll loading logging by windbg and `gflags /i Meld.exe +sls`
    showed that when MSYSTEM is defined then first directory where meld
    searches some DLL's *changes* from lib subdirectory
    to just meld dir itself. I didn't found the reason for it.
    This workarounds the problem by adding the required directory to PATH
    if meld is both frozen and is run with MSYSTEM defined.
    
    Problem description at https://gitlab.gnome.org/GNOME/meld/issues/267

 bin/meld | 16 +++++++++++++---
 1 file changed, 13 insertions(+), 3 deletions(-)
---
diff --git a/bin/meld b/bin/meld
index c8551c10..a3883d1d 100755
--- a/bin/meld
+++ b/bin/meld
@@ -355,10 +355,20 @@ def setup_glib_logging():
 
 
 def environment_hacks():
+    # MSYSTEM is set by git, and confuses our
+    # msys-packaged version's library search path -
+    # for frozen build the lib subdirectory is excluded.
+    # workaround it by adding as first path element.
+    # This may confuse vc utils run from meld
+    # but otherwise meld just crash on start, see #267
+
+    global frozen
+    if frozen and "MSYSTEM" in os.environ:
+        lib_dir = os.path.join(get_meld_dir(), "lib")
+        os.environ["PATH"] = lib_dir + os.pathsep + os.environ["PATH"]
     # We manage cwd ourselves for git operations, and GIT_DIR in particular
-    # can mess with this when set. MSYSTEM is set by git, and confuses our
-    # msys-packaged version's library search path.
-    for var in ('GIT_DIR', 'GIT_WORK_TREE', 'MSYSTEM'):
+    # can mess with this when set.
+    for var in ('GIT_DIR', 'GIT_WORK_TREE'):
         try:
             del os.environ[var]
         except KeyError:


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