Skip to content

Commit f6aa2bd

Browse files
authored
Fix --vips-info CLI flag with GLib >= 2.80 (#4251)
Use `g_log_writer_default_set_debug_domains()` since resetting `G_MESSAGES_DEBUG` at runtime has no effect for GLib >= 2.80. Also, remove any checks for the old `G_MESSAGES_DEBUG` env variable and overwrite it directly instead. This means the `--vips-info` CLI flag and the `VIPS_INFO=1` env variable now take precedence over `G_MESSAGES_DEBUG`. See: https://gitlab.gnome.org/GNOME/glib/-/merge_requests/3710.
1 parent a26dce4 commit f6aa2bd

File tree

2 files changed

+10
-15
lines changed

2 files changed

+10
-15
lines changed

ChangeLog

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
- fix PFM byte order on big-endian machines [agoode]
55
- morph: fix erode Highway path [kleisauke]
66
- morph: fix C-paths with masks containing zero [kleisauke]
7+
- fix `--vips-info` CLI flag with GLib >= 2.80 [kleisauke]
78

89
10/10/24 8.16.0
910

libvips/iofuncs/init.c

Lines changed: 9 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -363,24 +363,18 @@ set_stacksize(guint64 size)
363363
#endif /*HAVE_PTHREAD_DEFAULT_NP*/
364364
}
365365

366+
/**
367+
* Equivalent to setting the `G_MESSAGES_DEBUG=VIPS` environment variable.
368+
*/
366369
static void
367370
vips_verbose(void)
368371
{
369-
const char *old;
370-
371-
old = g_getenv("G_MESSAGES_DEBUG");
372-
373-
if (!old)
374-
g_setenv("G_MESSAGES_DEBUG", G_LOG_DOMAIN, TRUE);
375-
else if (!g_str_equal(old, "all") &&
376-
!g_strrstr(old, G_LOG_DOMAIN)) {
377-
char *new;
378-
379-
new = g_strconcat(old, " ", G_LOG_DOMAIN, NULL);
380-
g_setenv("G_MESSAGES_DEBUG", new, TRUE);
381-
382-
g_free(new);
383-
}
372+
#if GLIB_CHECK_VERSION(2, 80, 0)
373+
const char *domains[] = { G_LOG_DOMAIN, NULL };
374+
g_log_writer_default_set_debug_domains(domains);
375+
#else
376+
g_setenv("G_MESSAGES_DEBUG", G_LOG_DOMAIN, TRUE);
377+
#endif
384378
}
385379

386380
static int

0 commit comments

Comments
 (0)