Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion lib/python/gladevcp/hal_sourceview.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ def __init__(self, *a, **kw):
self.program_length = 0
self.idle_line_reset = True
self.buf = self.get_buffer()
self.buf.set_max_undo_levels(20)
# set_max_undo_levels is gone from newer GtkSourceView 4 releases
if hasattr(self.buf, 'set_max_undo_levels'):
self.buf.set_max_undo_levels(20)
self.buf.connect('changed', self.update_iter)
self.buf.connect('modified-changed', self.modified_changed)
self.lm = GtkSource.LanguageManager()
Expand Down
22 changes: 17 additions & 5 deletions src/emc/usr_intf/gmoccapy/gmoccapy.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,8 @@ def excepthook(exc_type, exc_obj, exc_tb):
return
try:
w = app.widgets.window1
except NameError:
except Exception:
# app not built (or partially built): parentless dialog
w = None
lines = traceback.format_exception(exc_type, exc_obj, exc_tb)
message ="Found an error!\nThe following information may be useful in troubleshooting:\n\n" + "".join(lines)
Expand All @@ -81,8 +82,10 @@ def excepthook(exc_type, exc_obj, exc_tb):
buttons = Gtk.ButtonsType.OK,)

m.show()
m.run()
m.destroy()
try:
m.run()
finally:
m.destroy()


sys.excepthook = excepthook
Expand Down Expand Up @@ -6605,12 +6608,21 @@ def _make_hal_pins(self):


# Exit on SIGTERM/SIGINT whether or not a main loop is running.
# Gtk.main_quit() does nothing outside a running loop, so quit the
# loop if one is active, otherwise exit the process.
# A modal dialog's gtk_dialog_run() loop is invisible to
# Gtk.main_quit(): destroy all other toplevels so run() returns and
# the unwind reaches Gtk.main(); force exit as a last resort.
def _force_exit():
LOG.warning("clean shutdown did not finish, forcing exit")
os._exit(0)

def _terminate(signum, frame):
LOG.info("gmoccapy received signal {}, shutting down".format(signum))
if Gtk.main_level() > 0:
Gtk.main_quit()
for w in Gtk.Window.list_toplevels():
if w is not app.widgets.window1:
w.destroy()
GLib.timeout_add(2000, _force_exit)
else:
sys.exit(0)
signal.signal(signal.SIGTERM, _terminate)
Expand Down