gvalue: Do copy non-interned strings

The G_VALUE_NOCOPY_CONTENTS for strings can only be used when collecting them
and not when copying them.

Instead only avoid copies for strings that are interned.

Fixes #2141
This commit is contained in:
Edward Hervey
2020-06-23 10:30:55 +00:00
committed by Philip Withnall
parent aa46b2405f
commit e21ab81ce0
3 changed files with 6 additions and 5 deletions

View File

@@ -148,11 +148,11 @@ test_value_string (void)
g_assert_cmpstr (str2, ==, static1);
g_free (str2);
/* Copying a static string gvalue should *not* copy the contents */
/* Copying a static string gvalue should *actually* copy the contents */
g_value_init (&copy, G_TYPE_STRING);
g_value_copy (&value, &copy);
copystr = g_value_get_string (&copy);
g_assert_true (copystr == static1);
g_assert_true (copystr != static1);
g_value_unset (&copy);
/* Setting a new string should change the contents */