GNOME Bugzilla – Bug 699550
Fix thread-safety issues with base_init() when registering an interface
Last modified: 2018-05-17 11:36:14 UTC
We should use default_init instead of base_init when registering interfaces Using base_init() is overly complex, requires multi-initialization guards, and in the case of vala generated code these are currently not thread safe. The recommended approach is to use default_init() to initialize interfaces. It is called only once, solves thread safety issues. The GObject tutorial was incorrect for many years in recommending base_init() but that has since been remedied. https://developer.gnome.org/gobject/stable/gtype-non-instantiable-classed.html#gtype-non-instantiable-classed-init https://developer.gnome.org/gobject/stable/howto-interface.html#howto-interface-define
Created attachment 243139 [details] [review] Use default_init instead of base_init when registering interfaces Using base_init() is overly complex, requires multi-initialization guards, and in the case of vala generated code these are currently not thread safe. The recommended approach is to use default_init() to initialize interfaces. It is called only once, solves thread safety issues.
Created attachment 243140 [details] A simple test case for looking over the changes
Attachment 243139 [details] pushed as 71f779e - Use default_init instead of base_init when registering interfaces