Hi
Is there a way of finding out when or whether the wx object referenced
in ruby is still alive?
Here''s my problem
# register that +wx_control+ should update on application events of type
+event_type+
def add_subscriber(wx_control, app_event_type)
@subscriptions[app_event_type].push(wx_control)
end
# later
def broadcast(app_event)
@subscriptions[app_event.type].each { | subscriber |
subscriber.notify(app_event) }
end
I have an application in which a ruby hash mapping subscribable
application events (like a new document being added) to controls which
should update their appearance on these events. Sometimes a control will
have been closed by the user, but is still in the subscribers list. When
an event is broadcast, its "notify" method is called, it gives a
"pure
virtual method call" error (wxruby 0.6.0).
I''ve tried several different things to clean up the subscribers list as
controls are destroyed, but without success:
WeakRef
ObjectSpace.define_finalizer(subscriber)
subscriber.evt_close() { | e | delete_subscriber(subscriber) }
The last seems to be the most promising, but it doesn''t work for all
the
control types that can be subscribers - only for frames. Is there
something universal to all Wx controls that I could try?
cheers
alex