Re: debug flags and g_type_init()
- From: Owen Taylor <otaylor redhat com>
- To: gtk-devel-list gnome org
- Cc: timj gtk org
- Subject: Re: debug flags and g_type_init()
- Date: 05 Jun 2001 17:43:14 -0400
Tim Janik <timj gtk org> writes:
> On 5 Jun 2001, Owen Taylor wrote:
>
> >
> > Currently:
> >
> > - g_type_init() can be called multiple times
> > - debug flags not set the first time will be silently ignored.
> >
> > So, in the rare case that someone wants to set the debug
> > flags, they have to do:
> >
> > g_type_init (my_debug_flags);
> >
> > gtk_init (&argc, &argv);
>
> right, unless they want debug flags parsed by gtk_init() take effect.
>
> > Why not remove the debug flags argument to g_type_init()
> > and have a separate g_type_set_debug_flags()? This has
> > the advantages:
> >
> > - We omit the mysterious 0 from g_type_init(0)
> > - We can put out a meaningful error if someone tries to
> > set the debug flags after GType is initialized.
>
> it also has disadvantages:
>
> a) things break if _g_type_debug_flags is evaluated after
> g_type_init() but before g_type_set_debug_flags() (currently
> this will be triggered when initializing the gobject class).
This wouldn't be allowed. g_type_set_debug_flags() need to be
called before g_type_init().
> for the future, we might even have per type-node debug info,
> at that point debug flags have to be known right at g_type_init()
> time (that's because g_type_init() already creates a couple type
> nodes)
By my proposal, debug flags have to be set before g_type_init().
> b) g_type_set_debug_flags() is yet another special function for the
> user to remember, to call _before_ any other function, together
> with (a), up to the extend of having to call g_type_set_debug_flags()
> even before g_type_init()
Make the special case (setting debugging flags) be in a single well
isolated function. I see no reason to mix it with g_type_init().
> c) not considering (a), your approach will cause the type system to
> puke upon gtk_init() if the user enabled certain debugging beforehand
Can you explain? I don't understand the difference between what I'm
proposing and the old thing where you had to call g_type_init() with
magic arguments before g_type_init() wad called by gtk_init().
> i don't think we can do much about not silently ignoring subsequent debug
> settings, unless we introduce something like g_type_is_initialized() which
> i think is taking the issue a bit to far.
> if people really dislike the "mysterious" 0 to g_type_init, we could
> however change things towards:
>
> void g_type_init (void);
> void g_type_init_with_debugging (GTypeDebugFlags debug_flags);
>
> both would still have to be silent upon subsequent invokations however.
The fact that g_type_init() is a function that can be called multiple
times with no effect is something we are relying on. This is the one
thing that keeps g_type_init() somewhat bearable to have present
at all.
So, mixing the debug flags in here, which have effect on the first
invocation, but not on subsequent invocations, just does not strike
me as a good thing, and I can't see the advantage in doing so
compared to a clean separate interface to set the debug flags.
If you want to set debug flags, then, you need to set them as the
very first thing in your program. It's simple and can be documented
right along with g_type_set_debug_flags().
Regards,
Owen
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]