COMPONENT_DETACHING is definetly wrong. It does not describe closing of
the frame. After such COMPONENT_DETACHING a COMPONENT_ATTACHING can
follow. That can happen incase the same is reused for loading another
component (document).
You have to listen as XCloseListener on every frame you created for a
callback notifyClosing(). Only here you can be sure, that a frame will
be closed. And only here you should remove your tab.
Question: How do you close the document inside the tab ?
>
> 2. Whenever a Component is disposed it calls the disposing() method
> of listeners attached to it. Those listeners should then clear all the
> references to this component, but there's no need to call
> removeEventListener()
> because that will be done inside the component itself. So, I added an
> event listener to the frame component, to check if it's being disposed.
If you are registered as e.g. XCloseListener on a frame, there is no
need to register yourself as XEventListener too. Because XCloseListener
is derived from XEventListener. And after XCloseListenr::notifyClosing()
a XEventListener::disposing() will be called automaticly.
OK - I see. For your purpose it's enough to react on disposing() call's
sent by the frame. Because there is not realy a different between
notifyClosing() and disposing(). In both cases the frame will die ...
and you have to veto against that.
Yes, pretty much. I ended up in implementing the cleanup code in the disposing() call
anyway.
It would be different in case your tabbed environment wishes to stop
closing of frames. But I dont see any reason here doing so.
=> forget the XCloseListener .. listen for disposing() events on frames only
OK, I think I'll do that, but for now I'll stick with closeListener for a while, for debug.
For me the dispatch code looks fine. For debugging purposes you can try
to close frames direct using the XCloseable API ...
You must get a notifyClosing() and disposing() event !
I figured that one too. And the results are promising. The notifyClosing is called,
and the frames are disposed !
But with dispatch they are not !
> 4. When the File->Exit is hit the notifyClosing() is called properly, I
> have some other
> problems here, but I'm still woking on it.
So you get this event on closing frames. Here my question again:
How do you clos your frames for testing ... using menu/toolbar ...?
Like I say - when I use the File->Exit command from the menu.
> 5. I have some problems with m_refCount, after cleaning everything up
> it's still up to 3,
> and that's even if I force the child frames to dispose :-/
> I can't find the reason for this yet.
That can be reasoned by your listener registrations.
If e.g. all frames was closed manually ( e.g. by using File->Close inside
every open frame) nobody will be responsible to close the TabControl and
it's windows. So your object will be registered e.g. as
XTopWindowListener and XWindowListener there.
You hold the TabControl alive ... and the TabControl holds you.
Such ring-references can be killed by dispose() e.g. the TabControl
explicitly.
I thought about that too. I think that here :
disposing()
{
if(event.Source is one of child frames)
{
childInfo = findChild(event.Source)
clear references in childInfo
remove childInfo from m_xChildren
// AND HERE WE COULD CHECK IF m_xChildren IS EMPTY :
if(m_xChildren is empty)
{
m_xTabControl.dispose()
// BUT !! it seems that I also have to explicitly call :
m_xTabParent.dispose()
m_xTopWindow.dispose()
// but I think it's because of some other problem. Those should be disposed
// automatically by the office
}
}
}
OK ... here the set of listener interfaces and callbacks, which should
be implemented by your component:
Here you do the following:
You call XDesktop::terminate() on the m_xDesktop instance (instead of
try to close all frames manually using the dispatch .-)
That will close all open documents (means frames).
Every closed frame will call you with disposing(xFrame).
(see e) what you has to do then ...)
If terminate() returns TRUE, you call dispose() on your m_xTabControl
member. That will call you back within XEventListener::disposing() for
- you registration on m_xTopWindow
- and your registration on m_xTabParentWindow
Forget these member references then.
OK! I like this idea. I thought about it yesterday, but then I thought that
xdesktop::Terminate is called automatically.
So I'm a bit confused here. I'll try to read more about this.
Normaly then all listener registrations should be gone.
all frames/documents should be closed ...
and the office itself should start it's real termination.
> Regards,
> Andrzej
Have fun .-)
Andreas
Yeah, thanks ;-)