From 32ada7135cf4e7789046e73424e19325ebf830e8 Mon Sep 17 00:00:00 2001 From: Angelo Naselli Date: Sun, 17 Jan 2021 18:41:06 +0100 Subject: Fixing gtk hang caused by glib loop used by yui-gtk too --- lib/isodumper.py | 35 +++++++++++++++++++---------------- 1 file changed, 19 insertions(+), 16 deletions(-) (limited to 'lib') diff --git a/lib/isodumper.py b/lib/isodumper.py index 9bde522..4770837 100755 --- a/lib/isodumper.py +++ b/lib/isodumper.py @@ -1,6 +1,6 @@ # coding:utf-8 -# !/usr/bin/python3 +# !/usr/bin/env python3 # # Copyright (c) 2007-2009 Canonical Ltd. # @@ -33,8 +33,7 @@ try: except: import version -sys.path.insert(0, '../../../build/swig/python3') -importlib.reload(sys) + ########### # imports # ########### @@ -530,8 +529,9 @@ class IsoDumper(object): self.write_logfile() self.dialog.destroy() self.dialog = None - self.glib_loop.quit() - self.glib_thread.join() + #TODO REMOVE if it works as it seems + #self.glib_loop.quit() + #self.glib_thread.join() def write_logfile(self): logpath = os.path.join(os.path.expanduser('~'), '.isodumper') @@ -722,18 +722,21 @@ exFAT, NTFS or ext. You can specify a volume name and the format in a new dialog self.dialog.recalcLayout() self.ancrage.showChild() self.uEventQueue = SimpleQueue() - self.glib_loop = GLib.MainLoop() - self.glib_thread = threading.Thread(target=self.glib_mainloop, args=(self.glib_loop,)) - self.glib_thread.start() - - - def glib_mainloop(self, loop): - ''' - thread function for glib main loop - listen to signal from udisks - ''' self.u.iface["org.freedesktop.DBus.ObjectManager"].InterfacesAdded.connect(self.device_changed) - loop.run() + #TODO REMOVE if it works as it seems + #self.glib_loop = GLib.MainLoop() + #self.glib_thread = threading.Thread(target=self.glib_mainloop, args=(self.glib_loop,)) + #self.glib_thread.start() + + #TODO REMOVE if it works as it seems + #def glib_mainloop(self, loop): + #''' + #thread function for glib main loop + #listen to signal from udisks + #''' + #self.u.iface["org.freedesktop.DBus.ObjectManager"].InterfacesAdded.connect(self.device_changed) + + #loop.run() def device_changed(self, a, b): self.uEventQueue.put({'event': "device-changed", 'value': True}) -- cgit v1.2.1 From 076f95aa050a773982ee536440f6dadeae55dfaf Mon Sep 17 00:00:00 2001 From: Angelo Naselli Date: Mon, 18 Jan 2021 22:36:30 +0100 Subject: Managed loop in TUI --- lib/isodumper.py | 34 +++++++++++++++++----------------- 1 file changed, 17 insertions(+), 17 deletions(-) (limited to 'lib') diff --git a/lib/isodumper.py b/lib/isodumper.py index 4770837..eba86c2 100755 --- a/lib/isodumper.py +++ b/lib/isodumper.py @@ -529,9 +529,10 @@ class IsoDumper(object): self.write_logfile() self.dialog.destroy() self.dialog = None - #TODO REMOVE if it works as it seems - #self.glib_loop.quit() - #self.glib_thread.join() + if yui.YUI.app().isTextMode(): + self.glib_loop.quit() + if yui.YUI.app().isTextMode(): + self.glib_thread.join() def write_logfile(self): logpath = os.path.join(os.path.expanduser('~'), '.isodumper') @@ -722,21 +723,20 @@ exFAT, NTFS or ext. You can specify a volume name and the format in a new dialog self.dialog.recalcLayout() self.ancrage.showChild() self.uEventQueue = SimpleQueue() + if yui.YUI.app().isTextMode(): + self.glib_loop = GLib.MainLoop() + self.glib_thread = threading.Thread(target=self.glib_mainloop, args=(self.glib_loop,)) + self.glib_thread.start() + self.u.iface["org.freedesktop.DBus.ObjectManager"].InterfacesAdded.connect(self.device_changed) - #TODO REMOVE if it works as it seems - #self.glib_loop = GLib.MainLoop() - #self.glib_thread = threading.Thread(target=self.glib_mainloop, args=(self.glib_loop,)) - #self.glib_thread.start() - - #TODO REMOVE if it works as it seems - #def glib_mainloop(self, loop): - #''' - #thread function for glib main loop - #listen to signal from udisks - #''' - #self.u.iface["org.freedesktop.DBus.ObjectManager"].InterfacesAdded.connect(self.device_changed) - - #loop.run() + + + def glib_mainloop(self, loop): + ''' + thread function for glib main loop + ''' + loop.run() + def device_changed(self, a, b): self.uEventQueue.put({'event': "device-changed", 'value': True}) -- cgit v1.2.1 From 018f2fd1f34d232497a0964b29a48497eb8b47af Mon Sep 17 00:00:00 2001 From: Papoteur Date: Wed, 20 Jan 2021 08:50:19 +0100 Subject: Fix signal when removing device --- lib/isodumper.py | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) (limited to 'lib') diff --git a/lib/isodumper.py b/lib/isodumper.py index eba86c2..d8387b4 100755 --- a/lib/isodumper.py +++ b/lib/isodumper.py @@ -531,7 +531,6 @@ class IsoDumper(object): self.dialog = None if yui.YUI.app().isTextMode(): self.glib_loop.quit() - if yui.YUI.app().isTextMode(): self.glib_thread.join() def write_logfile(self): @@ -729,7 +728,7 @@ exFAT, NTFS or ext. You can specify a volume name and the format in a new dialog self.glib_thread.start() self.u.iface["org.freedesktop.DBus.ObjectManager"].InterfacesAdded.connect(self.device_changed) - + self.u.iface["org.freedesktop.DBus.ObjectManager"].InterfacesRemoved.connect(self.device_changed) def glib_mainloop(self, loop): ''' -- cgit v1.2.1