[meld/cherry-pick-b1ff2409] Merge branch 'meld-3-18' into 'meld-3-18'



commit 4945155e9c7ba047af11bd36cc72e9bf5223064f
Author: Kai Willadsen <kai willadsen gmail com>
Date:   Thu May 31 20:22:35 2018 +0000

    Merge branch 'meld-3-18' into 'meld-3-18'
    
    Meld 3 18 - fix two bugs specific to frozen meld on win32
    
    See merge request GNOME/meld!8
    
    (cherry picked from commit b1ff2409ba65f2f23855aa3191ff66e8a65d38e7)
    
    810ef9e8 Provide dummy stdout to make multiprocessing work with cx_freeze GUI (#196)
    aafea319 Use external help in frozen installation, like uninstalled (#197)
    b37a6f06 win32 installer: include exe required to exec browser with meld help (#197)

 bin/meld         | 11 ++++++-----
 meld/conf.py     | 14 +++++++-------
 meld/meldapp.py  |  2 +-
 meld/settings.py |  2 +-
 setup_win32.py   |  2 ++
 5 files changed, 17 insertions(+), 14 deletions(-)
---
diff --git a/bin/meld b/bin/meld
index 66341776..84579a04 100755
--- a/bin/meld
+++ b/bin/meld
@@ -24,19 +24,20 @@ import subprocess
 import sys
 from multiprocessing import freeze_support
 
-# Main module hasn't multiprocessing workers, so not imported in subprocesses.
-# This allows skipping '__name__ == "main"' guard, but freezed case is special.
-freeze_support()
-
 # On Windows, pythonw.exe (which doesn't display a console window) supplies
 # dummy stdout and stderr streams that silently throw away any output. However,
 # these streams seem to have issues with flush() so we just redirect stdout and
 # stderr to actual dummy files (the equivalent of /dev/null).
 # Regarding pythonw.exe stdout, see also http://bugs.python.org/issue706263
-if sys.executable.endswith("pythonw.exe"):
+# Also cx_Freeze built with Win32GUI base sets sys.stdout to None
+# leading to exceptions in print() and freeze_support() that uses flush()
+if sys.executable.endswith("pythonw.exe") or sys.stdout is None:
     devnull = open(os.devnull, "w")
     sys.stdout = sys.stderr = devnull
 
+# Main module hasn't multiprocessing workers, so not imported in subprocesses.
+# This allows skipping '__name__ == "main"' guard, but freezed case is special.
+freeze_support()
 
 def disable_stdout_buffering():
 
diff --git a/meld/conf.py b/meld/conf.py
index 7ebb3af2..7c4a2c9b 100644
--- a/meld/conf.py
+++ b/meld/conf.py
@@ -9,8 +9,9 @@ __version__ = "3.19.1"
 DATADIR = os.path.join(sys.prefix, "share", "meld")
 LOCALEDIR = os.path.join(sys.prefix, "share", "locale")
 # END
-UNINSTALLED = False
-UNINSTALLED_SCHEMA = False
+
+# Flag enabling some workarounds if data dir isn't installed in standard prefix
+DATADIR_IS_UNINSTALLED = False
 PYTHON_REQUIREMENT_TUPLE = (3, 3)
 
 
@@ -24,13 +25,13 @@ ngettext = no_translation
 
 
 def frozen():
-    global DATADIR, LOCALEDIR, UNINSTALLED_SCHEMA
+    global DATADIR, LOCALEDIR, DATADIR_IS_UNINSTALLED
 
     melddir = os.path.dirname(sys.executable)
 
     DATADIR = os.path.join(melddir, "share", "meld")
     LOCALEDIR = os.path.join(melddir, "share", "mo")
-    UNINSTALLED_SCHEMA = True
+    DATADIR_IS_UNINSTALLED = True
 
     # This first bit should be unnecessary, but some things (GTK icon theme
     # location, GSettings schema location) don't fall back correctly.
@@ -40,14 +41,13 @@ def frozen():
 
 
 def uninstalled():
-    global DATADIR, LOCALEDIR, UNINSTALLED, UNINSTALLED_SCHEMA
+    global DATADIR, LOCALEDIR, DATADIR_IS_UNINSTALLED
     melddir = os.path.abspath(os.path.join(
         os.path.dirname(os.path.realpath(__file__)), ".."))
 
     DATADIR = os.path.join(melddir, "data")
     LOCALEDIR = os.path.join(melddir, "build", "mo")
-    UNINSTALLED = True
-    UNINSTALLED_SCHEMA = True
+    DATADIR_IS_UNINSTALLED = True
 
 
 def ui_file(filename):
diff --git a/meld/meldapp.py b/meld/meldapp.py
index a9e2f765..75bcc209 100644
--- a/meld/meldapp.py
+++ b/meld/meldapp.py
@@ -111,7 +111,7 @@ class MeldApp(Gtk.Application):
         meld.preferences.PreferencesDialog(self.get_active_window())
 
     def help_callback(self, action, parameter):
-        if meld.conf.UNINSTALLED:
+        if meld.conf.DATADIR_IS_UNINSTALLED:
             uri = "http://meldmerge.org/help/";
         else:
             uri = "help:meld"
diff --git a/meld/settings.py b/meld/settings.py
index 03ceac84..d7860cef 100644
--- a/meld/settings.py
+++ b/meld/settings.py
@@ -79,7 +79,7 @@ class MeldSettings(GObject.GObject):
 
 
 def load_settings_schema(schema_id):
-    if meld.conf.UNINSTALLED_SCHEMA:
+    if meld.conf.DATADIR_IS_UNINSTALLED:
         schema_source = Gio.SettingsSchemaSource.new_from_directory(
             meld.conf.DATADIR,
             Gio.SettingsSchemaSource.get_default(),
diff --git a/setup_win32.py b/setup_win32.py
index aa89b081..a7bbfe59 100644
--- a/setup_win32.py
+++ b/setup_win32.py
@@ -44,6 +44,8 @@ missing_dll = [
     'libharfbuzz-0.dll',
     'libharfbuzz-gobject-0.dll',
     'libwebp-5.dll',
+    # for Gtk.show_uri; note that name is bitness-dependant
+    'gspawn-win32-helper.exe',
 ]
 
 gtk_libs = [


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