From 14ce9baa44fec03d3d75c9871c45fa60b971c36e Mon Sep 17 00:00:00 2001 From: Dan Winship Date: Thu, 15 Sep 2011 09:39:09 -0400 Subject: module: fix module loading/unloading Force the module to stay resident after being loaded (otherwise it will crash if it's loaded, unloaded, and loaded again, because it will fail to register its types the second time). Also fix a few bugs in the unload() function, even though it is no longer used at this point. To be fixed for 3.4. https://bugzilla.gnome.org/show_bug.cgi?id=655979 --- modules/gtk3/caribou-gtk-module.vala | 8 +++----- modules/gtk3/caribou-module.c | 18 ++++++++---------- 2 files changed, 11 insertions(+), 15 deletions(-) (limited to 'modules') diff --git a/modules/gtk3/caribou-gtk-module.vala b/modules/gtk3/caribou-gtk-module.vala index a33f1a0..b50522b 100644 --- a/modules/gtk3/caribou-gtk-module.vala +++ b/modules/gtk3/caribou-gtk-module.vala @@ -13,7 +13,6 @@ namespace Caribou { private GLib.HashTable windows; private Keyboard keyboard; private Gdk.Display display; - private Atk.TextRectangle cursor_rect; public GtkModule () { windows = new GLib.HashTable (null, null); @@ -140,10 +139,9 @@ namespace Caribou { public void unload () { Gdk.window_remove_filter(null, event_filter); - windows = new GLib.HashTable (null, null); - cursor_rect.x = cursor_rect.y = cursor_rect.width = cursor_rect.height = 0; - keyboard = null; - display = null; + + foreach (Gtk.Window window in windows.get_keys ()) + window.notify["has-toplevel-focus"].disconnect (toplevel_focus_changed); } } diff --git a/modules/gtk3/caribou-module.c b/modules/gtk3/caribou-module.c index 90f0534..7792bd9 100644 --- a/modules/gtk3/caribou-module.c +++ b/modules/gtk3/caribou-module.c @@ -1,11 +1,7 @@ #include -#include #include "caribou-gtk-module.h" -#include -#define CARIBOU_LOCALDIR "" - -G_MODULE_EXPORT CaribouGtkModule * gtk_module; +CaribouGtkModule * gtk_module; G_MODULE_EXPORT CaribouGtkModule * gtk_module_init (gint *argc, gchar ***argv[]) { @@ -17,10 +13,12 @@ gtk_module_init (gint *argc, gchar ***argv[]) { G_MODULE_EXPORT const gchar* g_module_check_init (GModule *module) { - return gtk_check_version (GTK_MAJOR_VERSION, 0, 0); -} + const gchar *error; + + error = gtk_check_version (GTK_MAJOR_VERSION, 0, 0); + if (error) + return error; -G_MODULE_EXPORT void -g_module_unload(GModule *module) { - caribou_gtk_module_unload (gtk_module); + g_module_make_resident (module); + return NULL; } -- cgit v1.2.1