mirror of
https://gitlab.freedesktop.org/pipewire/wireplumber.git
synced 2026-05-05 05:28:01 +02:00
wplua: fix enum <-> lua conversion
Sometimes the GEnumClass is not instantiated, so _peek() doesn't work We need to acquire a strong ref to make sure it is
This commit is contained in:
parent
7ca6717ff9
commit
7b37b31af9
1 changed files with 2 additions and 2 deletions
|
|
@ -209,7 +209,7 @@ wplua_lua_to_gvalue (lua_State *L, int idx, GValue *v)
|
|||
break;
|
||||
case G_TYPE_ENUM:
|
||||
if (lua_type (L, idx) == LUA_TSTRING) {
|
||||
GEnumClass *klass = g_type_class_peek (G_VALUE_TYPE (v));
|
||||
g_autoptr (GEnumClass) klass = g_type_class_ref (G_VALUE_TYPE (v));
|
||||
GEnumValue *value = g_enum_get_value_by_nick (klass, lua_tostring (L, idx));
|
||||
if (value)
|
||||
g_value_set_enum (v, value->value);
|
||||
|
|
@ -283,7 +283,7 @@ wplua_gvalue_to_lua (lua_State *L, const GValue *v)
|
|||
wplua_pushobject (L, g_value_dup_object (v));
|
||||
break;
|
||||
case G_TYPE_ENUM: {
|
||||
GEnumClass *klass = g_type_class_peek (G_VALUE_TYPE (v));
|
||||
g_autoptr (GEnumClass) klass = g_type_class_ref (G_VALUE_TYPE (v));
|
||||
GEnumValue *value = g_enum_get_value (klass, g_value_get_enum (v));
|
||||
if (value)
|
||||
lua_pushstring (L, value->value_nick);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue