GNOME Bugzilla – Bug 686161
Deprecate g_type_init()
Last modified: 2012-11-06 14:54:28 UTC
We discussed this in Cambridge and everyone thought it was a good idea.
Created attachment 226472 [details] [review] Deprecate g_type_init() The recent removal of g_thread_init() has proven that constructors are supported widely enough to be used in libglib without trouble, so why not libgobject? Remove the need to call g_type_init() and deprecate it. Clean up various users (mostly testcases) throughout glib and remove some documentation mentions as well.
Can you do this patch in 3 parts? 1) Patch core glib to not require invoking g_type_init() 2) Patch all internal consumers 3) Deprecate g_type_init() Separating 1) and 2) just makes the patch a lot more reviewable, since you don't have to wade through a lot of two-line removals to find the meat. Separating 3) from the rest will allow us to debate whether it should be done right now. For projects that want to build on multiple GLib versions, and have multiple internal executables, it'll be pretty annoying. On the other hand, maybe the right thing to do is to tell those projects to use GLIB_MAX_VERSION_2_34 or whatever the macro is.
Created attachment 226482 [details] [review] Convert g_type_init() to a ctor Move the guts of g_type_init() into a ctor and turn g_type_init() itself into a do-nothing function. g_type_init_with_debug_flags() now ignores its arguments, but it has always been possible to achieve the same effect via environment variables.
Created attachment 226483 [details] [review] Remove g_type_init() calls Very many testcases, some GLib tools (resource compiler, etc) and GApplication were calling g_type_init(). Remove those uses, as they are no longer required.
Created attachment 226484 [details] [review] Properly deprecate g_type_init() Now that all internal users of it are gone.
Review of attachment 226482 [details] [review]: Minor comments...I wasn't at the discussion so I'd feel better if someone else (Matthias? Dan?) signed off on this patch. ::: gobject/gtype.c @@ +4257,3 @@ * + * This function used to initialise the type system with debugging + * flags. The type system is now initialised automatically and this Worth explicitly stating here "Since GLib 2.36, the type system is initialized automatically..." @@ +4258,3 @@ + * This function used to initialise the type system with debugging + * flags. The type system is now initialised automatically and this + * funciton does nothing. function @@ +4274,3 @@ + * + * This function used to initialise the type system. The type system is + * now initialised automatically and this funciton does nothing. Same comments here as apply to the doc above. @@ +4278,3 @@ +void +g_type_init (void) +{ We could add a g_assert (static_quark_type_flags) here or something, as a sanity check.
Review of attachment 226483 [details] [review]: Spot checks look fine, thanks for splitting up the patches!
Review of attachment 226484 [details] [review]: ::: gobject/gtype.c @@ +4263,3 @@ * environment variable. + * + * Deprecated: 2.36: g_type_init() is now done automatically I'd rather say "Type initialization is now performed automatically", rather than referring to a deprecated function in its own deprecation.
Review of attachment 226484 [details] [review]: ::: gobject/gtype.h @@ +651,3 @@ + * is now deprecated. + * + * Deprecated: 2.36: g_type_init() is now done automatically I think we should leave the text pointing at GOBJECT_DEBUG in here.
Review of attachment 226482 [details] [review]: Nothing to add to Colins comments.
Review of attachment 226484 [details] [review]: should still do the documentation improvements
Created attachment 226542 [details] [review] Convert g_type_init() to a ctor Move the guts of g_type_init() into a ctor and turn g_type_init() itself into a do-nothing function. g_type_init_with_debug_flags() now ignores its arguments, but it has always been possible to achieve the same effect via environment variables. Updated with all suggestions.
Created attachment 226543 [details] [review] Properly deprecate g_type_init() Now that all internal users of it are gone. Updated with all suggestions.
Attachment 226483 [details] pushed as 1dc774a - Remove g_type_init() calls Attachment 226542 [details] pushed as 7c42ab2 - Convert g_type_init() to a ctor Attachment 226543 [details] pushed as df02fa1 - Properly deprecate g_type_init()
See https://bugzilla.gnome.org/show_bug.cgi?id=687763 for libxul fallout.