Found the solution after so long. I needed the following function call
plugin_module_make_resident
in my module load function:
G_MODULE_EXPORT void geany_load_module(GeanyPlugin* plugin) {
// Step 1: set meta-data
// <snip>
// Step 2: set functions
plugin->funcs->init = projectview_v2_init;
plugin->funcs->cleanup = projectview_v2_cleanup;
plugin->funcs->configure = NULL;
plugin->funcs->help = NULL;
// Prevent segfault in plugin when it registers GTypes and gets unloaded
// and when reloaded tries to re-register the GTypes.
plugin_module_make_resident(plugin); // <-- needed this call
// Step 3: register
GEANY_PLUGIN_REGISTER(plugin, 248);
}
https://www.geany.org/manual/reference/pluginutils_8h.html#ac402e1d165036aaeb5ae1e176e536c36