Apache OpenOffice (AOO) Bugzilla – Issue 122405
[sidebar] UI element's real interface is disposed
Last modified: 2022-10-28 12:54:24 UTC
Created attachment 80743 [details] GDB backtrace Build the custompanel example from the SDK. Run the example. Attach the debugger. Set two break points: a) on the UI element's disposing() sd::colortoolpanel::PanelUIElement::disposing() b) on its tool panel disposing() sd::colortoolpanel::SingleColorPanel::disposing() Activate the custompanel on the sidebar, switch to the gallery or the navigator panel. sd::colortoolpanel::SingleColorPanel::disposing() is called before sd::colortoolpanel::PanelUIElement::disposing() sfx2::sidebar::Panel::Dispose() is disposing the UI element's real interface, then the UI element itself: if (mxElement.is()) { Reference<lang::XComponent> xComponent (mxElement->getRealInterface(), UNO_QUERY); if (xComponent.is()) xComponent->dispose(); } { Reference<lang::XComponent> xComponent (mxElement, UNO_QUERY); mxElement = NULL; if (xComponent.is()) xComponent->dispose(); } The real interface of the UI element is the UI element's responsibility (this means, when the UI element is disposed, it will free its resources, among other things, disposing its real interface - whatever that could be). In the custompanel example, this is handled nicely by the C++ component implementation helper class. In other cases, it may end up in a crash, as with the Watching Window extension from http://extensions.openoffice.org/en/project/watchingwindow
This is left-over from the early days of sidebar development when the Impress panels where still view shell based and needed very special handling and had to be disposed at exactly the right time. Disposing just the mxElement should be enough, now that the Impress panels are "regular" dialogs/controls.
"af" committed SVN revision 1487475 into trunk: 122405: Sidebar panels no longer dispose XUIElement's inner objects.
The object returned by XUIElement::getRealInterface() is no longer disposed(). The XUIElement interface does not state who is responsible for the returned object it seems reasonable to assume that the XUIElement object is. A quick look into two implementations of XUIElement confirms that.