Re: g_set_prgname()



Tim Janik <timj gtk org> writes:

> Sat Dec  8 16:12:10 2001  Christopher Blizzard  <blizzard redhat com>
> 
>         * gdk/gdk.c (gdk_init_check): Fallback to setting the prgname to
>         "<unknown>" if someone doesn't pass in a valid argc.  (Patch from
>         Fabrice Bellet <fabrice gnu org>, #54127).
> 
> this is a bad idea, you'd need to at least check g_get_prgname()
> before hand, since:
> 
>   g_set_prgname (argv[0]);
>   gtk_init (NULL, NULL);
>   g_print ("%s\n", g_get_prgname ());
> ==>"<unknown>"
>
> but even then, if g_get_prgname() was supposed to yield a program
> name, even if none was set, this change should go into GLib, not Gdk
> (or Gtk or GNOME or some other random module).
> but g_get_prgname() is actually supposed to return NULL if no program
> name was set, so code can do special casing when it doesn't know a
> program name, e.g. so you don't end up with multiple senseless
> window titles, upon doing something like:
> if (g_get_prgname ())
>   gtk_window_set_title (window, g_get_prgname ());

So, as not to confuse the issue, the change is just fixing a bug that crept
into GTK+-1.3. GTK+-1.2, contains, in gdk_init().

  if (argc && argv)
    {
      [...]
    }
  else
    {
      g_set_prgname ("<unknown>");
    }

Which this having been the behavior since at least 1997, before and
after the introduction of g_set_prgname().

So, what you are proposing is effectively an API change, at least as
compared to GTK+-1.2 - that if you call gtk_init() with a NULL argv,
then the prgname should be left NULL -- which makes me
uncomfortable since people may be using the results of g_get_prgname()
unconditionally.

I have no problems with making the enhancement you suggest and 
checking g_get_prgname() before calling g_set_prgname ("<unknown>")
since that can't hurt anything and removes a problem someone might
encounter.

Regards,
                                        Owen




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]