After an evaluation, GNOME has moved from Bugzilla to GitLab. Learn more about GitLab.
No new issues can be reported in GNOME Bugzilla anymore.
To report an issue in a GNOME project, go to GNOME GitLab.
Do not go to GNOME Gitlab for: Bluefish, Doxygen, GnuCash, GStreamer, java-gnome, LDTP, NetworkManager, Tomboy.
Bug 686161 - Deprecate g_type_init()
Deprecate g_type_init()
Status: RESOLVED FIXED
Product: glib
Classification: Platform
Component: gobject
unspecified
Other All
: Normal normal
: ---
Assigned To: gtkdev
gtkdev
Depends on:
Blocks:
 
 
Reported: 2012-10-15 14:45 UTC by Allison Karlitskaya (desrt)
Modified: 2012-11-06 14:54 UTC
See Also:
GNOME target: ---
GNOME version: ---


Attachments
Deprecate g_type_init() (68.26 KB, patch)
2012-10-15 14:45 UTC, Allison Karlitskaya (desrt)
none Details | Review
Convert g_type_init() to a ctor (8.12 KB, patch)
2012-10-15 16:01 UTC, Allison Karlitskaya (desrt)
needs-work Details | Review
Remove g_type_init() calls (59.26 KB, patch)
2012-10-15 16:02 UTC, Allison Karlitskaya (desrt)
committed Details | Review
Properly deprecate g_type_init() (2.43 KB, patch)
2012-10-15 16:02 UTC, Allison Karlitskaya (desrt)
needs-work Details | Review
Convert g_type_init() to a ctor (8.23 KB, patch)
2012-10-16 13:38 UTC, Allison Karlitskaya (desrt)
committed Details | Review
Properly deprecate g_type_init() (2.56 KB, patch)
2012-10-16 13:38 UTC, Allison Karlitskaya (desrt)
committed Details | Review

Description Allison Karlitskaya (desrt) 2012-10-15 14:45:36 UTC
We discussed this in Cambridge and everyone thought it was a good idea.
Comment 1 Allison Karlitskaya (desrt) 2012-10-15 14:45:41 UTC
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.
Comment 2 Colin Walters 2012-10-15 15:24:29 UTC
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.
Comment 3 Allison Karlitskaya (desrt) 2012-10-15 16:01:56 UTC
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.
Comment 4 Allison Karlitskaya (desrt) 2012-10-15 16:02:02 UTC
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.
Comment 5 Allison Karlitskaya (desrt) 2012-10-15 16:02:08 UTC
Created attachment 226484 [details] [review]
Properly deprecate g_type_init()

Now that all internal users of it are gone.
Comment 6 Colin Walters 2012-10-15 16:51:50 UTC
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.
Comment 7 Colin Walters 2012-10-15 16:53:26 UTC
Review of attachment 226483 [details] [review]:

Spot checks look fine, thanks for splitting up the patches!
Comment 8 Colin Walters 2012-10-15 16:54:40 UTC
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.
Comment 9 Matthias Clasen 2012-10-15 17:34:07 UTC
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.
Comment 10 Matthias Clasen 2012-10-15 17:35:45 UTC
Review of attachment 226482 [details] [review]:

Nothing to add to Colins comments.
Comment 11 Matthias Clasen 2012-10-15 17:36:57 UTC
Review of attachment 226484 [details] [review]:

should still do the documentation improvements
Comment 12 Allison Karlitskaya (desrt) 2012-10-16 13:38:37 UTC
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.
Comment 13 Allison Karlitskaya (desrt) 2012-10-16 13:38:57 UTC
Created attachment 226543 [details] [review]
Properly deprecate g_type_init()

Now that all internal users of it are gone.




Updated with all suggestions.
Comment 14 Allison Karlitskaya (desrt) 2012-10-16 13:39:54 UTC
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()
Comment 15 Colin Walters 2012-11-06 14:54:28 UTC
See https://bugzilla.gnome.org/show_bug.cgi?id=687763 for libxul fallout.