mirror of
https://gitlab.gnome.org/GNOME/glib.git
synced 2025-02-24 11:12:11 +01:00
glib/gmessages.c (g_log_default_handler) Move the Win32 code that asks the
2005-03-20 Tor Lillqvist <tml@novell.com> * glib/gmessages.c (g_log_default_handler) * glib/gutils.c (g_get_prgname): Move the Win32 code that asks the program name from the system to g_get_prgname(). Do output the pid also on Win32 (useful in case there are several instances of the same program running).
This commit is contained in:
parent
69aae7e623
commit
30a062866d
@ -8,6 +8,12 @@
|
||||
* glib/gtimer.c: On Win32, use GetSystemTimeAsFileTime() instead
|
||||
of GetTickCount(). (#159507)
|
||||
|
||||
* glib/gmessages.c (g_log_default_handler)
|
||||
* glib/gutils.c (g_get_prgname): Move the Win32 code that asks the
|
||||
program name from the system to g_get_prgname(). Do output the pid
|
||||
also on Win32 (useful in case there are several instances of the
|
||||
same program running).
|
||||
|
||||
2005-03-17 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* glib/gkeyfile.c: Update the documentation, reflecting the
|
||||
|
@ -8,6 +8,12 @@
|
||||
* glib/gtimer.c: On Win32, use GetSystemTimeAsFileTime() instead
|
||||
of GetTickCount(). (#159507)
|
||||
|
||||
* glib/gmessages.c (g_log_default_handler)
|
||||
* glib/gutils.c (g_get_prgname): Move the Win32 code that asks the
|
||||
program name from the system to g_get_prgname(). Do output the pid
|
||||
also on Win32 (useful in case there are several instances of the
|
||||
same program running).
|
||||
|
||||
2005-03-17 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* glib/gkeyfile.c: Update the documentation, reflecting the
|
||||
|
@ -8,6 +8,12 @@
|
||||
* glib/gtimer.c: On Win32, use GetSystemTimeAsFileTime() instead
|
||||
of GetTickCount(). (#159507)
|
||||
|
||||
* glib/gmessages.c (g_log_default_handler)
|
||||
* glib/gutils.c (g_get_prgname): Move the Win32 code that asks the
|
||||
program name from the system to g_get_prgname(). Do output the pid
|
||||
also on Win32 (useful in case there are several instances of the
|
||||
same program running).
|
||||
|
||||
2005-03-17 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* glib/gkeyfile.c: Update the documentation, reflecting the
|
||||
|
@ -8,6 +8,12 @@
|
||||
* glib/gtimer.c: On Win32, use GetSystemTimeAsFileTime() instead
|
||||
of GetTickCount(). (#159507)
|
||||
|
||||
* glib/gmessages.c (g_log_default_handler)
|
||||
* glib/gutils.c (g_get_prgname): Move the Win32 code that asks the
|
||||
program name from the system to g_get_prgname(). Do output the pid
|
||||
also on Win32 (useful in case there are several instances of the
|
||||
same program running).
|
||||
|
||||
2005-03-17 Matthias Clasen <mclasen@redhat.com>
|
||||
|
||||
* glib/gkeyfile.c: Update the documentation, reflecting the
|
||||
|
@ -879,53 +879,10 @@ g_log_default_handler (const gchar *log_domain,
|
||||
{
|
||||
const gchar *prg_name = g_get_prgname ();
|
||||
|
||||
#ifdef G_OS_WIN32
|
||||
if (prg_name)
|
||||
prg_name = g_strdup (prg_name);
|
||||
else
|
||||
{
|
||||
if (G_WIN32_HAVE_WIDECHAR_API ())
|
||||
{
|
||||
wchar_t buf[MAX_PATH+1];
|
||||
if (GetModuleFileNameW (GetModuleHandle (NULL),
|
||||
buf, G_N_ELEMENTS (buf)) > 0)
|
||||
{
|
||||
gchar *utf8_buf = g_utf16_to_utf8 (buf, -1,
|
||||
NULL, NULL, NULL);
|
||||
if (utf8_buf)
|
||||
{
|
||||
prg_name = g_path_get_basename (utf8_buf);
|
||||
g_free (utf8_buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
gchar buf[MAX_PATH+1];
|
||||
if (GetModuleFileNameA (GetModuleHandle (NULL),
|
||||
buf, G_N_ELEMENTS (buf)) > 0)
|
||||
{
|
||||
gchar *locale_buf = g_locale_to_utf8 (buf, -1, NULL, NULL, NULL);
|
||||
if (locale_buf)
|
||||
{
|
||||
prg_name = g_path_get_basename (locale_buf);
|
||||
g_free (locale_buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (prg_name)
|
||||
{
|
||||
g_string_append_printf (gstring, "(%s): ", prg_name);
|
||||
g_free ((gchar *) prg_name);
|
||||
}
|
||||
#else
|
||||
if (!prg_name)
|
||||
g_string_append_printf (gstring, "(process:%lu): ", (gulong)getpid ());
|
||||
else
|
||||
g_string_append_printf (gstring, "(%s:%lu): ", prg_name, (gulong)getpid ());
|
||||
#endif
|
||||
}
|
||||
|
||||
if (log_domain)
|
||||
|
@ -1599,6 +1599,38 @@ g_get_prgname (void)
|
||||
gchar* retval;
|
||||
|
||||
G_LOCK (g_prgname);
|
||||
#ifdef G_OS_WIN32
|
||||
if (g_prgname == NULL)
|
||||
{
|
||||
static gboolean beenhere = FALSE;
|
||||
|
||||
if (!beenhere)
|
||||
{
|
||||
gchar *utf8_buf = NULL;
|
||||
|
||||
beenhere = TRUE;
|
||||
if (G_WIN32_HAVE_WIDECHAR_API ())
|
||||
{
|
||||
wchar_t buf[MAX_PATH+1];
|
||||
if (GetModuleFileNameW (GetModuleHandle (NULL),
|
||||
buf, G_N_ELEMENTS (buf)) > 0)
|
||||
utf8_buf = g_utf16_to_utf8 (buf, -1, NULL, NULL, NULL);
|
||||
}
|
||||
else
|
||||
{
|
||||
gchar buf[MAX_PATH+1];
|
||||
if (GetModuleFileNameA (GetModuleHandle (NULL),
|
||||
buf, G_N_ELEMENTS (buf)) > 0)
|
||||
utf8_buf = g_locale_to_utf8 (buf, -1, NULL, NULL, NULL);
|
||||
}
|
||||
if (utf8_buf)
|
||||
{
|
||||
g_prgname = g_path_get_basename (utf8_buf);
|
||||
g_free (utf8_buf);
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif
|
||||
retval = g_prgname;
|
||||
G_UNLOCK (g_prgname);
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user