glib/gmessages.c (g_log_default_handler) Move the Win32 code that asks the
authorTor Lillqvist <tml@novell.com>
Sun, 20 Mar 2005 10:52:38 +0000 (10:52 +0000)
committerTor Lillqvist <tml@src.gnome.org>
Sun, 20 Mar 2005 10:52:38 +0000 (10:52 +0000)
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).

ChangeLog
ChangeLog.pre-2-10
ChangeLog.pre-2-12
ChangeLog.pre-2-8
glib/gmessages.c
glib/gutils.c

index 1b2bb12..3ffe87d 100644 (file)
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,5 +1,11 @@
 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).
+
        * tests/testglib.c (main): Print more detailled output from the
        timer tests. Don't print home directory twice. Test
        g_win32_error_message().
index 1b2bb12..3ffe87d 100644 (file)
@@ -1,5 +1,11 @@
 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).
+
        * tests/testglib.c (main): Print more detailled output from the
        timer tests. Don't print home directory twice. Test
        g_win32_error_message().
index 1b2bb12..3ffe87d 100644 (file)
@@ -1,5 +1,11 @@
 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).
+
        * tests/testglib.c (main): Print more detailled output from the
        timer tests. Don't print home directory twice. Test
        g_win32_error_message().
index 1b2bb12..3ffe87d 100644 (file)
@@ -1,5 +1,11 @@
 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).
+
        * tests/testglib.c (main): Print more detailled output from the
        timer tests. Don't print home directory twice. Test
        g_win32_error_message().
index 42019e6..55582fb 100644 (file)
@@ -883,53 +883,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)
index 95cf202..b07a95a 100644 (file)
@@ -1756,6 +1756,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);