virt-manager: Gracefully exit app on ctrl-c, not sys.exit

Will be needed for uitests coverage support
This commit is contained in:
Cole Robinson 2018-01-09 09:56:27 -05:00
parent 044d93d471
commit ab1b4f8628
2 changed files with 4 additions and 4 deletions

View File

@ -272,17 +272,17 @@ def main():
LibvirtGLib.init(None) LibvirtGLib.init(None)
LibvirtGLib.event_register() LibvirtGLib.event_register()
engine = vmmEngine()
# Actually exit when we receive ctrl-c # Actually exit when we receive ctrl-c
from gi.repository import GLib from gi.repository import GLib
def _sigint_handler(user_data): def _sigint_handler(user_data):
ignore = user_data ignore = user_data
logging.debug("Received KeyboardInterrupt. Exiting application.") logging.debug("Received KeyboardInterrupt. Exiting application.")
sys.exit(0) engine.exit_app(None)
GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT, GLib.unix_signal_add(GLib.PRIORITY_DEFAULT, signal.SIGINT,
_sigint_handler, None) _sigint_handler, None)
engine = vmmEngine()
engine.start(options.uri, show_window, domain, options.skip_autostart) engine.start(options.uri, show_window, domain, options.skip_autostart)

View File

@ -482,7 +482,7 @@ class vmmEngine(vmmGObject):
# Engine will always appear to leak # Engine will always appear to leak
objs.remove(self.object_key) objs.remove(self.object_key)
if src.object_key in objs: if src and src.object_key in objs:
# UI that initiates the app exit will always appear to leak # UI that initiates the app exit will always appear to leak
objs.remove(src.object_key) objs.remove(src.object_key)