Bug 42796 - Macro assigned to dataform Before Unload or While Unloading events are not called when form container is closed

Lionel Elie Mamane lionel at mamane.lu
Mon Apr 8 08:06:30 PDT 2013


On Wed, Mar 27, 2013 at 09:46:44AM +0000, mcmurchy1917-libreoffice at yahoo.co.uk wrote:

> In the bug report it was confirmed that a macro assigned to either
> the Before Unloading or When Unloading events of a dataform are not
> called when the form document is closed.

> However, when editing a form and the "Design Mode" option is toggled
> the events are called.

I completely missed that in my first reading of your mail:

 The *same* event (namely "Before Unloading" on the FormData) is:

 1) *not* called when closing the form document

 2) *called* when switching normal mode to design mode

So we need to see *what* codepath calls it in case "2)" (with the
msgbox / ctrl-c in gdb trick I described). That's already more or less
done, with Noel's quote of:

 FmFormView::ChangeDesignMode

 258     // --- 4. load resp. unload the forms
 259     FmFormPage*  pCurPage = GetCurPage();
 260     if ( pCurPage )
 261     {
 262         if ( pFormShell && pFormShell->GetImpl() )
 263             pFormShell->GetImpl()->loadForms( pCurPage, ( bDesign ? FORMS_UNLOAD : FORMS_LOAD ) );
 264     }

The operative call seems to be:
 pFormShell->GetImpl()->loadForms(pCurPage, FORMS_UNLOAD)

And then, we need to find where we need to call
 pFormShell->GetImpl()->loadForms(pCurPage, FORMS_UNLOAD)
in the case "1)". My idea for that is to see what triggers the *form*
*document* "before close" event (there does not seem to be a "before
unload" event for it). That codepath should call
 pFormShell->GetImpl()->loadForms(pCurPage, FORMS_UNLOAD)
somewhere

I've taken a look, and this the relevant part of the backtrace:


#36 0x00007f745fce2226 in SfxObjectShell::PrepareClose
(this=0x3d2a1a0, bUI=<optimized out>, 
    bForBrowsing=<optimized out>)
    at
    /home/master/src/libreoffice/workdirs/libreoffice-4.0/sfx2/source/doc/objxtor.cxx:596
#37 0x00007f742c1e82a7 in SwDocShell::PrepareClose (this=0x3d2a1a0,
bUI=<optimized out>, 
    bForBrowsing=<optimized out>)
    at
    /home/master/src/libreoffice/workdirs/libreoffice-4.0/sw/source/ui/app/docsh2.cxx:317
#38 0x00007f745fd87500 in SfxBaseController::suspend (this=0x3e89980,
bSuspend=<optimized out>)
    at
    /home/master/src/libreoffice/workdirs/libreoffice-4.0/sfx2/source/view/sfxbasecontroller.cxx:650
#39 0x00007f743c5a1955 in dbaccess::ODocumentDefinition::prepareClose
(this=0x31dfe30)
    at
    /home/master/src/libreoffice/workdirs/libreoffice-4.0/dbaccess/source/core/dataaccess/documentdefinition.cxx:2058
#40 0x00007f743c5b4c74 in dbaccess::OInterceptor::OnDispatch
(this=0x2ca0990, _pDispatcher=0x3d680f0)
    at
    /home/master/src/libreoffice/workdirs/libreoffice-4.0/dbaccess/source/core/dataaccess/intercept.cxx:192


But frankly, at this point I'm not sure how to get the "pFormShell"
and "pCurPage" somewhere in this call stack; I think we need to do
that in SwDocShell::PrepareClose or SfxObjectShell::PrepareClose
somehow.


Mcmurchy1917, I've also seen your email looking at the
"m_aLoadListeners.notifyEach( &XLoadListener::unloading, aEvt );"
That looks like a promising avenue, too.

-- 
Lionel


More information about the LibreOffice mailing list