Skip to content

Commit ebf3800

Browse files
committed
fix PropertyGetRevert
1 parent b54abf6 commit ebf3800

1 file changed

Lines changed: 13 additions & 3 deletions

File tree

classdb/register_properties.go

Lines changed: 13 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -294,6 +294,15 @@ func (instance *instanceImplementation) PropertyCanRevert(name gd.StringName) bo
294294
}); ok {
295295
return bool(impl.PropertyCanRevert(name.String()))
296296
}
297+
// When only PropertyGetRevert is implemented, a non-nil revert value implies the
298+
// property can be reverted (Godot calls _property_can_revert before _property_get_revert).
299+
if impl, ok := val.(interface {
300+
PropertyGetRevert(string) any
301+
}); ok {
302+
if impl.PropertyGetRevert(name.String()) != nil {
303+
return true
304+
}
305+
}
297306
sname := name.String()
298307
rtype := reflect.TypeOf(val).Elem()
299308
field, ok := rtype.FieldByName(sname)
@@ -318,10 +327,11 @@ func (instance *instanceImplementation) PropertyGetRevert(name gd.StringName) (g
318327
return gd.Variant{}, false
319328
}
320329
if impl, ok := val.(interface {
321-
PropertyGetRevert(string) (any, bool)
330+
PropertyGetRevert(string) any
322331
}); ok {
323-
val, ok := impl.PropertyGetRevert(name.String())
324-
return gd.NewVariant(val), ok
332+
if v := impl.PropertyGetRevert(name.String()); v != nil {
333+
return gd.NewVariant(v), true
334+
}
325335
}
326336
sname := name.String()
327337
rtype := reflect.TypeOf(val).Elem()

0 commit comments

Comments
 (0)