[Github-comments] [geany] plugins: pass GModule * to geany_load_module() (#719)

Colomban Wendling notifications at xxxxx
Sat Nov 14 17:32:46 UTC 2015


> I would agree to either drop this PR as @kugel suggested or postpone it to 1.27.

We can't really postpone it, as it changes the new plugin API, and then would mean we break the new API from 1.26 in 1.27 :)

But apparently we agree to drop this.  IMO we should document this, so what about something like this:
```diff
diff --git a/src/pluginutils.c b/src/pluginutils.c
index e48b4c1..4470313 100644
--- a/src/pluginutils.c
+++ b/src/pluginutils.c
@@ -92,6 +92,24 @@ void plugin_add_toolbar_item(GeanyPlugin *plugin, GtkToolItem *item)
  *
  * @param plugin Must be @ref geany_plugin.
  *
+ * @warning This cannot be used from inside `geany_load_module()` using the new plugin API.
+ * You generally should only call this from your plugin's `GeanyPluginFuncs::init()`
+ * function if possible to avoid possible extra resource usage when your plugin isn't
+ * actually activated. If you really need your module to be resident whenever it has been
+ * loaded (i.e. you create GTypes directly in your `geany_load_module()`), you need to use
+ * GLib's
+ * [g_module_check_init()](https://developer.gnome.org/glib/stable/glib-Dynamic-Loading-of-Modules.html#GModuleCheckInit)
+ * hook and call
+ * [g_module_make_resident()](https://developer.gnome.org/glib/unstable/glib-Dynamic-Loading-of-Modules.html#g-module-make-resident)
+ * from there:
+ * @code
+ * const gchar *g_module_check_init(GModule *module)
+ * {
+ *  g_module_make_resident(module);
+ *  return NULL;
+ * }
+ * @endcode
+ *
  *  @since 0.16
  */
 GEANY_API_SYMBOL
```
Which gives:
![capture d ecran 2015-11-14 a 18 31 24](https://cloud.githubusercontent.com/assets/793526/11164884/fb433cce-8afd-11e5-9cdf-24aac16c0b9f.png)



---
Reply to this email directly or view it on GitHub:
https://github.com/geany/geany/pull/719#issuecomment-156722007
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://lists.geany.org/pipermail/github-comments/attachments/20151114/4e631d87/attachment.html>


More information about the Github-comments mailing list