<div dir="ltr"><div><div><div><div>Hi<br><br></div>After entering ToolBarManager::RemoveControllers, I put a break point on SvxFontNameBox_Impl::~SvxFontNameBox_Impl and then did mpWindow.clear() in gdb (where mpWindow is the SvxFontNameBox_Impl object wrapped in VclPtr).<br></div>But gdb did not show a call on the dtor ~SvxFontNameBox_Impl. After further digging, I found that the mnRefCnt of the mpWindow in question was <span style="color:rgb(255,0,0)"><b>219</b></span> just before the VclPtr was reset.<br></div>Now I wonder who else increased the ref count of this mpWindow object, why the value is so high and how to proceed from here ?<br><br></div><div>Thanks,<br></div><div>Dennis<br></div></div><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 26, 2015 at 4:23 PM, Dennis Francis <span dir="ltr"><<a href="mailto:dennisfrancis.in@gmail.com" target="_blank">dennisfrancis.in@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Sorry, I understand now that pItem->mpWindow is a smart pointer (VclPtr). So the issue may be elsewhere.<br><br>Thanks,<br>Dennis<b><span style="color:rgb(255,0,0)"><br></span></b></div><div class="HOEnZb"><div class="h5"><div class="gmail_extra"><br><div class="gmail_quote">On Wed, Aug 26, 2015 at 3:42 PM, Dennis Francis <span dir="ltr"><<a href="mailto:dennisfrancis.in@gmail.com" target="_blank">dennisfrancis.in@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div dir="ltr">Hi Caolán and Maxim<br><div><div class="gmail_extra"><br></div><div class="gmail_extra">Thanks for your replies, My reply is inline.<br><br><div class="gmail_quote"><span>On Tue, Aug 25, 2015 at 7:38 PM, Caolán McNamara <span dir="ltr"><<a href="mailto:caolanm@redhat.com" target="_blank">caolanm@redhat.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><span>
</span>Digging into the other examples, I guess that SetItemWindow was called<br>
on the toolbar with the SvxFontNameBox_Impl window as an argument ?<br></blockquote></span><div>yes. <br></div><span><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
If that's the case then the pattern appears to be that what object<br>
called SetItemWindow on the toolbar should call SetItemWindow(id, 0) to<br>
remove the window from the toolbar and then call disposeAndClear on the<br>
window.<br>
<br>
i.e. what entity put the item into the toolbar is the same entity that<br>
has to remove it and dispose it.<br>
<br>
What's the reproducing scenario here, is it the fontname widget in the<br>
standard toolbar, e.g. just start and exit writer to reproduce ?<br></blockquote><div> </div></span><div>I think it should work with writer too, I ran soffice --calc and opened a new spreadsheet and then closed it. <br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<span><font color="#888888"><br>
C.<br>
</font></span></blockquote></div><br></div><div class="gmail_extra">Here is what I observe in gdb :<br>===========================================================================<br>breakpoints were set on : <br>SvxFontNameBox_Impl::SvxFontNameBox_Impl()<br>SvxFontNameBox_Impl::FillList()<br>SvxFontNameBox_Impl::~SvxFontNameBox_Impl()<br><br>Order of calls observed from gdb each with address of SvxFontNameBox_Impl object :<br>1. (SvxFontNameBox_Impl * const) 0x1cd4290, SvxFontNameBox_Impl::SvxFontNameBox_Impl - from toolbar code<br>2. (SvxFontNameBox_Impl * const) 0x1cd4290, SvxFontNameBox_Impl::FillList<br>3. (SvxFontNameBox_Impl * const) 0x1e60cc0, SvxFontNameBox_Impl::SvxFontNameBox_Impl  - from sidebar::ControllerFactory<br>4. (SvxFontNameBox_Impl * const) 0x1e60cc0, SvxFontNameBox_Impl::~SvxFontNameBox_Impl - sidebar<br>5. (SvxFontNameBox_Impl * const) 0x1e60cc0, SvxFontNameBox_Impl::~SvxFontNameBox_Impl - sidebar<br><br><br>No call of destructor SvxFontNameBox_Impl::~SvxFontNameBox_Impl() for the instance 0x1cd4290<br>==============================================================================<br><br></div><div class="gmail_extra">I tried setting break point on framework::ToolBarManager::RemoveControllers and it calls SetItemWindow(id, 0) for all items :<br>m_pToolBar->SetItemWindow(nItemId, 0);<br><br>But in ToolBox::SetItemWindow() method, I think the pItem->mpWindow is just overwritten and not getting deleted. Is the deletion code missing here ?<br></div><div class="gmail_extra">Is it ok to add<br><br></div><div class="gmail_extra"> if (pItem->mpWindow)<br></div><div class="gmail_extra">    delete pItem->mpWindow;<br><br></div><div class="gmail_extra">before assigning pNewWindow to it ?<br></div><div class="gmail_extra"><br><br>   1296 void ToolBox::SetItemWindow( sal_uInt16 nItemId, vcl::Window* pNewWindow )<br>   1297 {<br>   1298     sal_uInt16 nPos = GetItemPos( nItemId );<br>   1299 <br>   1300     if ( nPos != TOOLBOX_ITEM_NOTFOUND )<br>   1301     {<br>   1302         ImplToolItem* pItem = &mpData->m_aItems[nPos];<br>   1303        <b> <span style="color:rgb(255,0,0)">pItem->mpWindow = pNewWindow;</span></b><br>   1304         if ( pNewWindow )<br>   1305             pNewWindow->Hide();<br>   1306         ImplInvalidate( true );<br>   1307         CallEventListeners( VCLEVENT_TOOLBOX_ITEMWINDOWCHANGED, reinterpret_cast< void* >( nPos ) );<br>   1308     }<br>   1309 }<br><br></div><div class="gmail_extra">Thanks,<br></div><div class="gmail_extra">Dennis<br><br><a href="http://www.ldcs.co.in" target="_blank">http://www.ldcs.co.in</a><br></div></div></div>
</blockquote></div><br></div>
</div></div></blockquote></div><br></div>