[gnumeric] Fix signal handling while running Python. [#744638]



commit 73ccd1ba33e21e194e1c65b5ef60b1401a19a659
Author: Jean Brefort <jean brefort normalesup org>
Date:   Mon Mar 30 16:46:12 2015 +0200

    Fix signal handling while running Python. [#744638]

 NEWS                               |    3 +++
 plugins/python-loader/ChangeLog    |    5 +++++
 plugins/python-loader/gnm-python.c |   11 +++++++++++
 3 files changed, 19 insertions(+), 0 deletions(-)
---
diff --git a/NEWS b/NEWS
index 8923094..95c1ea8 100644
--- a/NEWS
+++ b/NEWS
@@ -4,6 +4,9 @@ Andreas:
        * Improve ODF import/export of additional axes. [#746321]
        * Fix ODF export of styles for additional axes. [#746621]
 
+Jean:
+       * Fix signal handling while running Python. [#744638]
+
 Morten:
        * xlsx import/export of log axis.
        * xlsx export of multiple plots in chart.
diff --git a/plugins/python-loader/ChangeLog b/plugins/python-loader/ChangeLog
index 03373a7..b8af588 100644
--- a/plugins/python-loader/ChangeLog
+++ b/plugins/python-loader/ChangeLog
@@ -1,3 +1,8 @@
+2015-03-30  Jean Brefort  <jean brefort normalesup org>
+
+       * gnm-python.c (cb_test_signals), (gnm_python_init),
+       (gnm_python_finalize): busy wait for signals. [#744638]
+
 2015-03-04  Morten Welinder <terra gnome org>
 
        * Release 1.12.21
diff --git a/plugins/python-loader/gnm-python.c b/plugins/python-loader/gnm-python.c
index a9b01c9..209faf0 100644
--- a/plugins/python-loader/gnm-python.c
+++ b/plugins/python-loader/gnm-python.c
@@ -45,6 +45,14 @@ static GObjectClass *parent_class = NULL;
 
 static GnmPython *gnm_python_obj = NULL;
 
+static int
+cb_test_signals (void)
+{
+       if (PyErr_CheckSignals () < 0)
+               exit (0);
+       return TRUE;
+}
+
 static void
 gnm_python_init (GnmPython *gpy)
 {
@@ -53,6 +61,8 @@ gnm_python_init (GnmPython *gpy)
        gpy->interpreters = g_slist_append (NULL, gpy->default_interpreter);
        g_return_if_fail (gnm_python_obj == NULL);
        gnm_python_obj = gpy;
+       g_timeout_add_full (G_PRIORITY_LOW, 100, (GSourceFunc) cb_test_signals,
+                           gnm_python_obj, NULL);
 }
 
 static void
@@ -60,6 +70,7 @@ gnm_python_finalize (GObject *obj)
 {
        GnmPython *gpy = GNM_PYTHON (obj);
 
+       g_source_remove_by_user_data (gnm_python_obj);
        if (gpy->default_interpreter != NULL) {
                GO_SLIST_FOREACH (gpy->interpreters, GnmPyInterpreter, interpreter,
                        if (interpreter != gpy->default_interpreter) {


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]