HOB:Proper handle of SIGINT
PATCH 1/1 HOB:Proper handle of SIGINT
Modal dialogs doesn't run on the main loop so they cannot catch any signal from the terminal. This patch makes sure the dialogs are destroyed when a SIGINT is sent to HOB.
--- bitbake/lib/bb/ui/crumbs/builder.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)
bitbake/lib/bb/ui/crumbs/builder.py +11 -2
@@ -30,6 +30,7 @@ import shlex import re import logging import sys +import signal from bb.ui.crumbs.imageconfigurationpage import ImageConfigurationPage from bb.ui.crumbs.recipeselectionpage import RecipeSelectionPage from bb.ui.crumbs.packageselectionpage import PackageSelectionPage
@@ -441,6 +442,8 @@ class Builder(gtk.Window): self.initiate_new_build_async() + signal.signal(signal.SIGINT, self.event_handle_SIGINT) + def create_visual_elements(self): self.set_title("Hob") self.set_icon_name("applications-development")
@@ -1028,7 +1031,7 @@ class Builder(gtk.Window): dialog.destroy() self.build_failed() - def handler_task_started_cb(self, running_build, message): + def handler_task_started_cb(self, running_build, message): fraction = message["current"] * 1.0/message["total"] title = "Build packages" if self.current_step == self.FAST_IMAGE_GENERATING:
@@ -1075,6 +1078,12 @@ class Builder(gtk.Window): else: gtk.main_quit() + def event_handle_SIGINT(self, signal, frame): + for w in gtk.window_list_toplevels(): + if w.get_modal(): + w.response(gtk.RESPONSE_DELETE_EVENT) + sys.exit(0) + def build_packages(self): _, all_recipes = self.recipe_model.get_selected_recipes() if not all_recipes:
@@ -1090,7 +1099,7 @@ class Builder(gtk.Window): def build_image(self): selected_packages = self.package_model.get_selected_packages() - if not selected_packages: + if not selected_packages: lbl = "<b>No selections made</b>\nYou have not made any selections" lbl = lbl + " so there isn't anything to bake at this time." dialog = CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)
Signature · 1 line
1.8.1.2
Hi Valentin,
Quoted 60 lines · On Wednesday 03 July 2013 14:31:44 Valentin Popa wrote:
Modal dialogs doesn't run on the main loop so they cannot catch any signal from the terminal. This patch makes sure the dialogs are destroyed when a SIGINT is sent to HOB.
[YOCTO #3329]Signed-off-by Valentin Popa <[email protected]>--- bitbake/lib/bb/ui/crumbs/builder.py | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-)(quoted diff) +0
-0
b/bitbake/lib/bb/ui/crumbs/builder.pyindex d5df60f..a2abb2a 100755bitbake/lib/bb/ui/crumbs/builder.py +11
-2@@ -30,6 +30,7 @@ import shlex import re import logging import sys +import signal from bb.ui.crumbs.imageconfigurationpage import ImageConfigurationPage from bb.ui.crumbs.recipeselectionpage import RecipeSelectionPage from bb.ui.crumbs.packageselectionpage import PackageSelectionPage@@ -441,6 +442,8 @@ class Builder(gtk.Window): self.initiate_new_build_async() + signal.signal(signal.SIGINT, self.event_handle_SIGINT) + def create_visual_elements(self): self.set_title("Hob") self.set_icon_name("applications-development")@@ -1028,7 +1031,7 @@ class Builder(gtk.Window): dialog.destroy() self.build_failed() - def handler_task_started_cb(self, running_build, message): + def handler_task_started_cb(self, running_build, message): fraction = message["current"] * 1.0/message["total"] title = "Build packages" if self.current_step == self.FAST_IMAGE_GENERATING:@@ -1075,6 +1078,12 @@ class Builder(gtk.Window): else: gtk.main_quit() + def event_handle_SIGINT(self, signal, frame): + for w in gtk.window_list_toplevels(): + if w.get_modal(): + w.response(gtk.RESPONSE_DELETE_EVENT) + sys.exit(0) + def build_packages(self): _, all_recipes = self.recipe_model.get_selected_recipes() if not all_recipes:@@ -1090,7 +1099,7 @@ class Builder(gtk.Window): def build_image(self): selected_packages = self.package_model.get_selected_packages() - if not selected_packages: + if not selected_packages: lbl = "<b>No selections made</b>\nYou have not made any
Quoted 2 lines
selections" lbl = lbl + " so there isn't anything to bake at this time." dialog =
CrumbsMessageDialog(self, lbl, gtk.STOCK_DIALOG_INFO)
This patch has been merged, however without the unrelated whitespace changes. If we want to make whitespace changes they should be done in a separate patch.
Cheers,
Paul
Signature · 2 lines
Paul Eggleton Intel Open Source Technology Centre