Commit 4bbdc18b authored by Paolo Borelli's avatar Paolo Borelli Committed by Paolo Borelli

gedit/gedit-plugins-engine.[ch] gedit/gedit-python-module.[ch]


2006-01-06  Paolo Borelli  <pborelli@katamail.com>

	* gedit/gedit-plugins-engine.[ch]
	* gedit/gedit-python-module.[ch]
	* gedit/gedit-window.c:

	Run the python Garbage Collector when closing a window or a tab
	in order to force python to release references to our objects.
parent 2493140e
2006-01-06 Paolo Borelli <pborelli@katamail.com>
* gedit/gedit-plugins-engine.[ch]
* gedit/gedit-python-module.[ch]
* gedit/gedit-window.c:
Run the python Garbage Collector when closing a window or a tab
in order to force python to release references to our objects.
2006-01-06 Paolo Borelli <pborelli@katamail.com>
* gedit/gedit-plugin.[ch]:
......
......@@ -341,6 +341,14 @@ gedit_plugins_engine_init (void)
return TRUE;
}
void
gedit_plugins_engine_garbage_collect (void)
{
#ifdef ENABLE_PYTHON
gedit_python_garbage_collect ();
#endif
}
void
gedit_plugins_engine_shutdown (void)
{
......@@ -385,6 +393,10 @@ gedit_plugins_engine_shutdown (void)
g_object_unref (gedit_plugins_engine_gconf_client);
gedit_plugins_engine_gconf_client = NULL;
#ifdef ENABLE_PYTHON
gedit_python_shutdown ();
#endif
}
const GList *
......
......@@ -39,6 +39,8 @@ typedef struct _GeditPluginInfo GeditPluginInfo;
gboolean gedit_plugins_engine_init (void);
void gedit_plugins_engine_shutdown (void);
void gedit_plugins_engine_garbage_collect (void);
const GList *gedit_plugins_engine_get_plugins_list (void);
gboolean gedit_plugins_engine_activate_plugin (GeditPluginInfo *info);
......
......@@ -302,3 +302,46 @@ gedit_python_module_new (const gchar *path,
return result;
}
/* --- these are not module methods, they are here out of convenience --- */
static gint idle_garbage_collect_id = 0;
static gboolean
run_gc (gpointer data)
{
while (PyGC_Collect ())
;
idle_garbage_collect_id = 0;
return FALSE;
}
void
gedit_python_garbage_collect (void)
{
if (Py_IsInitialized() && idle_garbage_collect_id == 0)
{
idle_garbage_collect_id = g_idle_add (run_gc, NULL);
}
}
void
gedit_python_shutdown (void)
{
if (Py_IsInitialized ())
{
if (idle_garbage_collect_id != 0)
{
g_source_remove (idle_garbage_collect_id);
idle_garbage_collect_id = 0;
}
while (PyGC_Collect ())
;
Py_Finalize ();
}
}
......@@ -56,6 +56,13 @@ GeditPythonModule *gedit_python_module_new (const gchar* path,
GObject *gedit_python_module_new_object (GeditPythonModule *module);
/* --- python utils --- */
void gedit_python_garbage_collect (void);
void gedit_python_shutdown (void);
G_END_DECLS
#endif
......@@ -165,6 +165,8 @@ gedit_window_destroy (GtkObject *object)
g_object_unref (window->priv->recent_view_uim);
window->priv->recent_view_uim = NULL;
}
gedit_plugins_engine_garbage_collect();
GTK_OBJECT_CLASS (gedit_window_parent_class)->destroy (object);
}
......@@ -233,6 +235,13 @@ gedit_window_key_press_event (GtkWidget *widget,
return GTK_WIDGET_CLASS (gedit_window_parent_class)->key_press_event (widget, event);
}
static void
gedit_window_tab_removed (GeditWindow *window,
GeditTab *tab)
{
gedit_plugins_engine_garbage_collect();
}
static void
gedit_window_class_init (GeditWindowClass *klass)
{
......@@ -240,6 +249,8 @@ gedit_window_class_init (GeditWindowClass *klass)
GtkObjectClass *gobject_class = GTK_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
klass->tab_removed = gedit_window_tab_removed;
object_class->finalize = gedit_window_finalize;
object_class->get_property = gedit_window_get_property;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment