GNOME Bugzilla – Bug 621317
[ModuleInit] uses function that does not exist
Last modified: 2010-06-21 08:35:17 UTC
Created attachment 163414 [details] generated ccode for plugin.vala With vala-0.9.1 release the usage of plugins was changed. Unfortunately this gives me a bug that prevents the overall usage of plugins. I changed the example from http://live.gnome.org/Vala/TypeModules to work in the new way, that requires a TypeModule argument in the register function of [ModuleInit]. The PluginRegistrar in the changed example derrives from TypeModule and uses a reference to itself as argument for the register function. Looking at the generated ccode of the plugin, in the "register_plugin" function there is a call to "test_plugin_register_type" - a function that was declared in the plugin, but does not exist. This leads to a symbol lookup error: ./main: symbol lookup error: /home/me/plugin-example/libplugin.so: undefined symbol: test_plugin_register_type I attach the files to this bug report
Created attachment 163417 [details] plugin vala code
Created attachment 163419 [details] main vala code
Created attachment 163420 [details] plugin interface vala code
Created attachment 163421 [details] generated ccode for main
Created attachment 163422 [details] generated ccode for the plugin-interface
bug is related to this one https://bugzilla.gnome.org/show_bug.cgi?id=553928 and just requires a patch to vala's gobject.vapi. Patch by Abderrahim Kitouni: diff --git a/vapi/gobject-2.0.vapi b/vapi/gobject-2.0.vapi index a3876d3..3b0d70f 100644 --- a/vapi/gobject-2.0.vapi +++ b/vapi/gobject-2.0.vapi @@ -98,15 +98,15 @@ namespace GLib { public interface TypePlugin { } - [CCode (lower_case_csuffix = "type_module")] - public class TypeModule : Object, TypePlugin { + [CCode (lower_case_csuffix = "type_module", unref_function = "")] + public abstract class TypeModule : Object, TypePlugin { public bool use (); public void unuse (); public void set_name (string name); [NoWrapper] - public virtual bool load (); + public abstract bool load (); [NoWrapper] - public virtual void unload (); + public abstract void unload (); } [CCode (type_id = "G_TYPE_PARAM", ref_function = "g_param_spec_ref", unref_function = "g_param_spec_unref", param_spec_function = "g_param_spec_param", get_value_function = "g_value_get_param", set_value_function = "g_value_set_param", take_value_function = "g_value_take_param")]
http://mail.gnome.org/archives/vala-list/2010-June/msg00068.html
Using abstract here makes sense, however, avoiding unref sounds like a workaround. If you make sure that the TypeModule instance stays alive long enough by storing it in an appropriate variable or field, this should not be necessary. Can you elaborate on why you needed this?
(In reply to comment #8) > Using abstract here makes sense, however, avoiding unref sounds like a > workaround. If you make sure that the TypeModule instance stays alive long > enough by storing it in an appropriate variable or field, this should not be > necessary. Can you elaborate on why you needed this? Well, that's what I undestood from the docs (the unuse method): Decreases the use count of a GTypeModule by one. If the result is zero, the module will be unloaded. (However, the GTypeModule will not be freed, and types associated with the GTypeModule are not unregistered. Once a GTypeModule is initialized, it must exist forever.) After I posted this, I thought it better to also remove the ref function (if it's never going to be destroyed, no need to count the references either)
Is the patch considered as acceptable? Maybe then it could go into the mainline. Thanks for taking care on this bug! Regards Jörn