summaryrefslogtreecommitdiff
path: root/gio/giomodule.c
diff options
context:
space:
mode:
authorHyunjee Kim <hj0426.kim@samsung.com>2019-12-03 10:42:37 +0900
committerHyunjee Kim <hj0426.kim@samsung.com>2019-12-03 10:42:37 +0900
commit99d572044d3b94498607a05ad7aaccf372e8cbff (patch)
tree7c5dad139ba0b85031a7378639e419b108e10659 /gio/giomodule.c
parenta60402374ac62bf99a22f84f0801d5513b12fd66 (diff)
downloadglib-99d572044d3b94498607a05ad7aaccf372e8cbff.tar.gz
glib-99d572044d3b94498607a05ad7aaccf372e8cbff.tar.bz2
glib-99d572044d3b94498607a05ad7aaccf372e8cbff.zip
Imported Upstream version 2.59.1
Diffstat (limited to 'gio/giomodule.c')
-rw-r--r--gio/giomodule.c61
1 files changed, 59 insertions, 2 deletions
diff --git a/gio/giomodule.c b/gio/giomodule.c
index 36c0cefed..b92162dcc 100644
--- a/gio/giomodule.c
+++ b/gio/giomodule.c
@@ -700,6 +700,35 @@ try_class (GIOExtension *extension,
return NULL;
}
+static void
+print_help (const char *envvar,
+ GIOExtensionPoint *ep)
+{
+ g_print ("Supported arguments for %s environment variable:\n", envvar);
+
+ if (g_io_extension_point_get_extensions (ep) == NULL)
+ g_print (" (none)\n");
+ else
+ {
+ GList *l;
+ GIOExtension *extension;
+ int width = 0;
+
+ for (l = g_io_extension_point_get_extensions (ep); l; l = l->next)
+ {
+ extension = l->data;
+ width = MAX (width, strlen (g_io_extension_get_name (extension)));
+ }
+
+ for (l = g_io_extension_point_get_extensions (ep); l; l = l->next)
+ {
+ extension = l->data;
+
+ g_print (" %*s - %d\n", width, g_io_extension_get_name (extension), g_io_extension_get_priority (extension));
+ }
+ }
+}
+
/**
* _g_io_module_get_default_type:
* @extension_point: the name of an extension point
@@ -766,6 +795,12 @@ _g_io_module_get_default_type (const gchar *extension_point,
}
use_this = envvar ? g_getenv (envvar) : NULL;
+ if (g_strcmp0 (use_this, "help") == 0)
+ {
+ print_help (envvar, ep);
+ use_this = NULL;
+ }
+
if (use_this)
{
preferred = g_io_extension_point_get_extension_by_name (ep, use_this);
@@ -874,7 +909,7 @@ _g_io_module_get_default (const gchar *extension_point,
const char *use_this;
GList *l;
GIOExtensionPoint *ep;
- GIOExtension *extension, *preferred;
+ GIOExtension *extension = NULL, *preferred;
gpointer impl;
g_rec_mutex_lock (&default_modules_lock);
@@ -885,6 +920,8 @@ _g_io_module_get_default (const gchar *extension_point,
if (g_hash_table_lookup_extended (default_modules, extension_point,
&key, &impl))
{
+ /* Don’t debug here, since we’re returning a cached object which was
+ * already printed earlier. */
g_rec_mutex_unlock (&default_modules_lock);
return impl;
}
@@ -899,23 +936,32 @@ _g_io_module_get_default (const gchar *extension_point,
if (!ep)
{
+ g_debug ("%s: Failed to find extension point ‘%s’",
+ G_STRFUNC, extension_point);
g_warn_if_reached ();
g_rec_mutex_unlock (&default_modules_lock);
return NULL;
}
use_this = envvar ? g_getenv (envvar) : NULL;
+ if (g_strcmp0 (use_this, "help") == 0)
+ {
+ print_help (envvar, ep);
+ use_this = NULL;
+ }
+
if (use_this)
{
preferred = g_io_extension_point_get_extension_by_name (ep, use_this);
if (preferred)
{
impl = try_implementation (extension_point, preferred, verify_func);
+ extension = preferred;
if (impl)
goto done;
}
else
- g_warning ("Can't find module '%s' specified in %s", use_this, envvar);
+ g_warning ("Can't find module '%s' specified in %s", use_this, envvar);
}
else
preferred = NULL;
@@ -939,6 +985,17 @@ _g_io_module_get_default (const gchar *extension_point,
impl ? g_object_ref (impl) : NULL);
g_rec_mutex_unlock (&default_modules_lock);
+ if (impl != NULL)
+ {
+ g_assert (extension != NULL);
+ g_debug ("%s: Found default implementation %s (%s) for ‘%s’",
+ G_STRFUNC, g_io_extension_get_name (extension),
+ G_OBJECT_TYPE_NAME (impl), extension_point);
+ }
+ else
+ g_debug ("%s: Failed to find default implementation for ‘%s’",
+ G_STRFUNC, extension_point);
+
return impl;
}