Skip to content
Permalink
Browse files

externalapp: use os.startfile on windows

Use the nonportable os.startfile() way of working on Windows to workaround
a segfault. Users will no longer be offered a choice of what to launch on
that platform: use Explorer to set the default edit association for the
extension you want to edit instead.

Addresses #531 enough to have it not hinder the release, but
this is a pretty silly workaround for an upstream GLib/GDK regression.
  • Loading branch information...
achadwick committed Dec 18, 2015
1 parent 8059e64 commit abdaf83e81cfa5dcc59a0f8c5671ca0e7153d7ce
Showing with 22 additions and 0 deletions.
  1. +22 −0 gui/externalapp.py
@@ -17,6 +17,7 @@
logger = logging.getLogger(__name__)
import weakref
import os.path
import os

from lib.gettext import gettext as _
from lib.gettext import C_
@@ -229,6 +230,25 @@ def begin(self, layer):
except AttributeError:
return
file_path = new_edit_tempfile()
if os.name == 'nt':
self._begin_file_edit_using_startfile(file_path, layer)
# Avoid segfault: https://github.com/mypaint/mypaint/issues/531
# Upstream: https://bugzilla.gnome.org/show_bug.cgi?id=758248
else:
self._begin_file_edit_using_gio(file_path, layer)
self._begin_file_monitoring_using_gio(file_path, layer)

def _begin_file_edit_using_startfile(self, file_path, layer):
logger.info("Using os.startfile() to edit %r", file_path)
os.startfile(file_path, "edit")
self._doc.app.show_transient_message(
_LAUNCH_SUCCESS_MSG.format(
app_name = "(unknown Win32 app)", # FIXME: needs i18n
layer_name = layer.name,
))

def _begin_file_edit_using_gio(self, file_path, layer):
logger.info("Using OpenWithDialog and GIO to open %r", file_path)
logger.debug("Querying file path for info")
file = Gio.File.new_for_path(file_path)
flags = Gio.FileQueryInfoFlags.NONE
@@ -279,6 +299,8 @@ def begin(self, layer):
app_name=appinfo.get_name(),
layer_name=layer.name,
))

def _begin_file_monitoring_using_gio(self, file_path, layer):
self._cleanup_stale_monitors(added_layer=layer)
logger.debug("Begin monitoring %r for changes (layer=%r)",
file_path, layer)

0 comments on commit abdaf83

Please sign in to comment.
You can’t perform that action at this time.