changeset 22495:2ded253bcdbb

Uninitialize the python interpreter only if gnt started it. This fixes a crash when quitting pygnt apps.
author Sadrul Habib Chowdhury <imadil@gmail.com>
date Tue, 18 Mar 2008 02:13:24 +0000
parents 22fef6b952a0
children 7505f555ab3e a1652ea8f252 e4a4bc86c547
files finch/libgnt/gntwm.c
diffstat 1 files changed, 10 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/finch/libgnt/gntwm.c	Mon Mar 17 20:32:02 2008 +0000
+++ b/finch/libgnt/gntwm.c	Tue Mar 18 02:13:24 2008 +0000
@@ -101,6 +101,7 @@
 static gboolean idle_update;
 static GList *act = NULL; /* list of WS with unseen activitiy */
 static gboolean ignore_keys = FALSE;
+static gboolean started_python = FALSE;
 
 static GList *
 g_list_bring_to_front(GList *list, gpointer data)
@@ -1342,7 +1343,10 @@
 		wm->workspaces = g_list_delete_link(wm->workspaces, wm->workspaces);
 	}
 #ifdef USE_PYTHON
-	Py_Finalize();
+	if (started_python) {
+		Py_Finalize();
+		started_python = FALSE;
+	}
 #endif
 }
 
@@ -1523,8 +1527,11 @@
 #ifdef USE_PYTHON
 	gnt_bindable_class_register_action(GNT_BINDABLE_CLASS(klass), "run-python", run_python,
 				GNT_KEY_F3, NULL);
-	Py_SetProgramName("gnt");
-	Py_Initialize();
+	if (!Py_IsInitialized()) {
+		Py_SetProgramName("gnt");
+		Py_Initialize();
+		started_python = TRUE;
+	}
 #endif
 
 	gnt_style_read_actions(G_OBJECT_CLASS_TYPE(klass), GNT_BINDABLE_CLASS(klass));