gnome-python-desktop r540 - trunk/evince



Author: gjc
Date: Thu Feb  5 18:51:49 2009
New Revision: 540
URL: http://svn.gnome.org/viewvc/gnome-python-desktop?rev=540&view=rev

Log:
Call ev_shutdown() on a python atexit handler; closes #570622.

Modified:
   trunk/evince/evincemodule.c

Modified: trunk/evince/evincemodule.c
==============================================================================
--- trunk/evince/evincemodule.c	(original)
+++ trunk/evince/evincemodule.c	Thu Feb  5 18:51:49 2009
@@ -12,6 +12,16 @@
 
 extern PyMethodDef pyevince_functions[];
 
+PyObject *
+_wrap_ev_shutdown (void)
+{
+/*     g_message("ev_shutdown();"); */
+    ev_shutdown();
+    Py_INCREF(Py_None);
+    return Py_None;
+}
+
+
 DL_EXPORT(void)
 initevince(void)
 {
@@ -36,4 +46,14 @@
     if (PyErr_Occurred ()) {
         return;
     }
+
+      /* Call ev_shutdown() on an atexit handler (bug #570622) */
+    {
+        // note: py_atexit_method_def has to be static, since python keeps a pointer to it
+        static PyMethodDef py_atexit_method_def = {NULL, (PyCFunction)_wrap_ev_shutdown, METH_NOARGS, NULL};
+        PyObject *py_atexit_func = PyCFunction_NewEx(&py_atexit_method_def, NULL, NULL);
+        PyObject *atexit = PyImport_ImportModule("atexit");
+        PyObject_CallMethod(atexit, "register", "N", py_atexit_func);
+        Py_DECREF(atexit);
+    }
 }



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