From 1b6438e8ff4a7dfd9ff09bc19ba2bb3c7e1edbb1 Mon Sep 17 00:00:00 2001 From: Richard Hughes Date: Tue, 4 Oct 2022 08:32:00 +0100 Subject: [PATCH] trivial: Only set the fallback builtin plugin name when required We only want to use the gtype-generated name if the plugin has not already used fu_plugin_set_name() to set a custom name. --- libfwupdplugin/fu-plugin.c | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/libfwupdplugin/fu-plugin.c b/libfwupdplugin/fu-plugin.c index 6dbc6e57e..511831b25 100644 --- a/libfwupdplugin/fu-plugin.c +++ b/libfwupdplugin/fu-plugin.c @@ -2839,11 +2839,17 @@ fu_plugin_finalize(GObject *object) FuPlugin * fu_plugin_new_from_gtype(GType gtype, FuContext *ctx) { - g_autofree gchar *name = NULL; + FuPlugin *self; + g_return_val_if_fail(gtype != G_TYPE_INVALID, NULL); g_return_val_if_fail(ctx == NULL || FU_IS_CONTEXT(ctx), NULL); - name = fu_plugin_convert_gtype_to_name(gtype); - return g_object_new(gtype, "context", ctx, "name", name, NULL); + + self = g_object_new(gtype, "context", ctx, NULL); + if (fu_plugin_get_name(self) == NULL) { + g_autofree gchar *name = fu_plugin_convert_gtype_to_name(gtype); + fu_plugin_set_name(self, name); + } + return self; } /**