Commit da3ba746 authored by Kai Willadsen's avatar Kai Willadsen

filediff: Work around GtkSourceView load failure (final part of #152)

When GtkSourceView's loader fails to load due to a unicode decode issue,
at least one of the failure cases doesn't actually end the in-progress
user action (see bgo#795387). Because we use user-actions to handle both
our undo stack and also our sensitivity setting (i.e., we disable some
things while you're in the middle of a user action) this breaks several
things across the Meld UI, basically putting us in a very weird state.

The workaround here is... not good, but it's the best we can do for now.
If/when the GtkSourceView side of this gets fixed, we'll end up with a
lot of GTK+ critical logs, but everything *should* continue to work.
parent a7bb4281
......@@ -1140,6 +1140,20 @@ class FileDiff(MeldDoc, Component):
try:
loader.load_finish(result)
except GLib.Error as err:
if err.matches(
GLib.convert_error_quark(),
GLib.ConvertError.ILLEGAL_SEQUENCE):
# While there are probably others, this is the main
# case where GtkSourceView's loader doesn't finish its
# in-progress user-action on error. See bgo#795387 for
# the GtkSourceView bug report.
#
# The handling here is fragile, but it's better than
# getting into a non-obvious corrupt state.
buf = loader.get_buffer()
buf.end_not_undoable_action()
buf.end_user_action()
# TODO: Find sane error domain constants
if err.domain == 'gtk-source-file-loader-error':
# TODO: Add custom reload-with-encoding handling for
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment