gutils: assert against calling g_set_application_name()

g_set_application_name() guards against being reset, but it doesn't
remember whether it was set, it only checks whether g_application_name
was set to non-NULL. When allowing g_set_application_name(NULL) that leads
to odd behaviors, like:

    g_set_application_name(NULL);
    g_set_application_name("foo");

would not warn.

Disallow that and assert against a NULL application_name.

Note that application_name argument is also not marked as "(nullable)".
This commit is contained in:
Thomas Haller 2023-11-08 08:31:10 +01:00
parent 167deee94d
commit 0d61895ef1

View File

@ -1233,6 +1233,8 @@ g_set_application_name (const gchar *application_name)
{
gboolean already_set = FALSE;
g_return_if_fail (application_name);
G_LOCK (g_application_name);
if (g_application_name)
already_set = TRUE;