diff --git a/main/gbx/gbx_c_observer.c b/main/gbx/gbx_c_observer.c index 1b6350b39..a0b41f3a5 100644 --- a/main/gbx/gbx_c_observer.c +++ b/main/gbx/gbx_c_observer.c @@ -132,6 +132,20 @@ BEGIN_PROPERTY(Observer_Tag) END_PROPERTY +BEGIN_METHOD_VOID(Observer_Detach) + + OBJECT_EVENT *ev; + + if (!THIS->object) + return; + + ev = OBJECT_event(THIS->object); + LIST_remove((void **)&ev->observer, THIS, &THIS->list); + THIS->object = NULL; + OBJECT_UNREF(_object); + +END_METHOD + #endif GB_DESC NATIVE_Observer[] = @@ -144,5 +158,7 @@ GB_DESC NATIVE_Observer[] = GB_PROPERTY_READ("Object", "o", Observer_Object), GB_PROPERTY("Tag", "v", Observer_Tag), + GB_METHOD("Detach", NULL, Observer_Detach, NULL), + GB_END_DECLARE };