You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany/pull/1234
-- Commit Summary --
* Allow plugins to get the data they set
-- File Changes --
M src/plugindata.h (1) M src/pluginutils.c (16)
-- Patch Links --
https://github.com/geany/geany/pull/1234.patch https://github.com/geany/geany/pull/1234.diff
Ammended to add `@see geany_plugin_set_data()` reference.
elextr commented on this pull request.
Guess its reasonable to get the data you set :)
@@ -554,6 +554,24 @@ void plugin_builder_connect_signals(GeanyPlugin *plugin,
}
+/** Get the additional data that corresponds to the plugin. + * + * @param plugin The plugin provided by Geany + * @return The data corresponding to the plugin or @c NULL if none set. + * + * @since 1.29 (API 230) + * + * @see geany_plugin_set_data() + */ +gpointer geany_plugin_get_data(const GeanyPlugin *plugin) +{ + g_return_val_if_fail (plugin != NULL, NULL); + g_return_val_if_fail (PLUGIN_LOADED_OK (plugin->priv), NULL);
These should be normal `if(..)return val` because they should not be removable by compile option as the `g_...` checks are.
codebrainz commented on this pull request.
@@ -554,6 +554,24 @@ void plugin_builder_connect_signals(GeanyPlugin *plugin,
}
+/** Get the additional data that corresponds to the plugin. + * + * @param plugin The plugin provided by Geany + * @return The data corresponding to the plugin or @c NULL if none set. + * + * @since 1.29 (API 230) + * + * @see geany_plugin_set_data() + */ +gpointer geany_plugin_get_data(const GeanyPlugin *plugin) +{ + g_return_val_if_fail (plugin != NULL, NULL); + g_return_val_if_fail (PLUGIN_LOADED_OK (plugin->priv), NULL);
They check programming errors and so should be removed for non-debug builds.
elextr commented on this pull request.
@@ -554,6 +554,24 @@ void plugin_builder_connect_signals(GeanyPlugin *plugin,
}
+/** Get the additional data that corresponds to the plugin. + * + * @param plugin The plugin provided by Geany + * @return The data corresponding to the plugin or @c NULL if none set. + * + * @since 1.29 (API 230) + * + * @see geany_plugin_set_data() + */ +gpointer geany_plugin_get_data(const GeanyPlugin *plugin) +{ + g_return_val_if_fail (plugin != NULL, NULL); + g_return_val_if_fail (PLUGIN_LOADED_OK (plugin->priv), NULL);
Indeed, but plugins are external code, and can pass bad parameters at any time. All functions in the API should be permanently checked. (yes Geany is not consistent about that, but you can have the honour of being the first to get it right :)
codebrainz commented on this pull request.
@@ -554,6 +554,24 @@ void plugin_builder_connect_signals(GeanyPlugin *plugin,
}
+/** Get the additional data that corresponds to the plugin. + * + * @param plugin The plugin provided by Geany + * @return The data corresponding to the plugin or @c NULL if none set. + * + * @since 1.29 (API 230) + * + * @see geany_plugin_set_data() + */ +gpointer geany_plugin_get_data(const GeanyPlugin *plugin) +{ + g_return_val_if_fail (plugin != NULL, NULL); + g_return_val_if_fail (PLUGIN_LOADED_OK (plugin->priv), NULL);
Look at [the function below](https://github.com/geany/geany/pull/1234/commits/84720babfbce2642289a8c03813...) this one. I copied the pre-conditions but added an additional one for the `plugin != NULL` for good measure.
@codebrainz @elextr this can be closed (was commited to master as 7261742f8169b19fd5ac7f10a0845a684287e2d9)
Closed #1234.
github-comments@lists.geany.org