[Glade-devel] [glade3, patch] load library module before calling *_get_type ()



Nice :-) (although I didn't try this patch, you'll have to wait for others 
to commit).

Anyways hope you stick around glade-3 Tommi (could make you famous). :-)

Here's to another contributer. Yay!
Archit

Tommi Komulainen <tommi komulainen nokia com> writes:

Hi,

Please find attached a patch that moves loading of the library module
before the call to foo_get_type() that's supposedly in that library. 
With the patch I was able to get custom widgets to appear in glade
palette.


-- 
Tommi Komulainen <tommi komulainen nokia com>

--- ChangeLog 2003-11-29 15:44:43.000000000 +0200
+++ ChangeLog 2004-01-08 18:14:27.000000000 +0200
@@ -1,3 +1,9 @@
+2004-01-08  Tommi Komulainen  <tommi komulainen nokia com>
+
+     * src/glade-widget-class.c: load the library module before attempting
+     to call *_get_type since the function could be located in dependent
+     libraries.
+
 2003-11-29  Paolo Borelli  <pborelli katamail com>
 
      * widgets/gtkmenubar.xml: override fill_empty with ignore.
--- src/glade-widget-class.c  2003-11-19 18:24:10.000000000 +0200
+++ src/glade-widget-class.c  2004-01-08 16:34:05.000000000 +0200
@@ -498,6 +498,7 @@ glade_widget_class_new (const char *name
      char *filename = NULL;
      char *library = NULL;
      char *init_function_name = NULL;
+     GModule *module = NULL;
      GType parent_type;
 
      g_return_val_if_fail (name != NULL, NULL);
@@ -526,10 +527,19 @@ glade_widget_class_new (const char *name
                      g_warning (_("Not enough memory."));
                      goto lblError;
              }
+
+             module = g_module_open (library, G_MODULE_BIND_LAZY);
+             if (!module)
+             {
+                     g_warning (_("Unable to open the module %s."), library);
+                     goto lblError;
+             }
      }
 
      widget_class = g_new0 (GladeWidgetClass, 1);
 
+     widget_class->module = module;
+
      widget_class->generic_name = generic_name ? g_strdup (generic_name) : NULL;
      widget_class->name = g_strdup (name);
      widget_class->in_palette = generic_name ? TRUE : FALSE;
@@ -564,16 +574,6 @@ glade_widget_class_new (const char *name
 
      widget_class->icon = glade_widget_class_create_icon (widget_class);
 
-     if (library)
-     {
-             widget_class->module = g_module_open (library, G_MODULE_BIND_LAZY);
-             if (!widget_class->module)
-             {
-                     g_warning (_("Unable to open the module %s."), library);
-                     goto lblError;
-             }
-     }
-
      g_free (init_function_name);
 
      for (parent_type = g_type_parent (widget_class->type);




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