You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@openoffice.apache.org by zh...@apache.org on 2012/09/14 15:26:29 UTC
svn commit: r1384759 - in /incubator/ooo/trunk/main/sw: inc/doc.hxx
source/core/doc/docnew.cxx source/core/doc/docxforms.cxx
Author: zhangjf
Date: Fri Sep 14 13:26:29 2012
New Revision: 1384759
URL: http://svn.apache.org/viewvc?rev=1384759&view=rev
Log:
#i113606#, in SwDoc dtor to release the cyclic reference between XFormModel and bindings/submissions
Patch by: zhangjf
Review by: zhangjf
Modified:
incubator/ooo/trunk/main/sw/inc/doc.hxx
incubator/ooo/trunk/main/sw/source/core/doc/docnew.cxx
incubator/ooo/trunk/main/sw/source/core/doc/docxforms.cxx
Modified: incubator/ooo/trunk/main/sw/inc/doc.hxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/inc/doc.hxx?rev=1384759&r1=1384758&r2=1384759&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/inc/doc.hxx (original)
+++ incubator/ooo/trunk/main/sw/inc/doc.hxx Fri Sep 14 13:26:29 2012
@@ -2082,6 +2082,8 @@ public:
void initXForms( bool bCreateDefaultModel );
// <-- #i31958# access methods for XForms model(s)
+ void disposeXForms( ); // #i113606#, for disposing XForms
+
// --> OD 2006-03-21 #b6375613#
inline bool ApplyWorkaroundForB6375613() const
{
Modified: incubator/ooo/trunk/main/sw/source/core/doc/docnew.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/core/doc/docnew.cxx?rev=1384759&r1=1384758&r2=1384759&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/core/doc/docnew.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/core/doc/docnew.cxx Fri Sep 14 13:26:29 2012
@@ -683,6 +683,8 @@ SwDoc::~SwDoc()
maListStyleLists.clear();
// <--
+ disposeXForms(); // #i113606#, dispose the XForms objects
+
delete pPrtData;
delete pNumberFormatter;
delete pFtnInfo;
Modified: incubator/ooo/trunk/main/sw/source/core/doc/docxforms.cxx
URL: http://svn.apache.org/viewvc/incubator/ooo/trunk/main/sw/source/core/doc/docxforms.cxx?rev=1384759&r1=1384758&r2=1384759&view=diff
==============================================================================
--- incubator/ooo/trunk/main/sw/source/core/doc/docxforms.cxx (original)
+++ incubator/ooo/trunk/main/sw/source/core/doc/docxforms.cxx Fri Sep 14 13:26:29 2012
@@ -37,7 +37,7 @@
#include <com/sun/star/xforms/XFormsUIHelper1.hpp>
#include <unotools/processfactory.hxx>
#include <tools/diagnose_ex.h>
-
+#include <com/sun/star/container/XIndexAccess.hpp>
using namespace ::com::sun::star;
@@ -51,7 +51,7 @@ using xforms::XModel;
using frame::XModule;
using xforms::XFormsUIHelper1;
using rtl::OUString;
-
+using com::sun::star::container::XIndexAccess;
Reference<XNameContainer> SwDoc::getXForms() const
{
@@ -117,3 +117,52 @@ void SwDoc::initXForms( bool bCreateDefa
DBG_UNHANDLED_EXCEPTION();
}
}
+
+//
+// #i113606#, to release the cyclic reference between XFormModel and bindings/submissions.
+//
+void SwDoc::disposeXForms( )
+{
+ // get XForms models
+ if( xXForms.is() )
+ {
+ // iterate over all models
+ uno::Sequence<OUString> aNames = xXForms->getElementNames();
+ const OUString* pNames = aNames.getConstArray();
+ sal_Int32 nNames = aNames.getLength();
+ for( sal_Int32 n = 0; (n < nNames); n++ )
+ {
+ Reference< xforms::XModel > xModel(
+ xXForms->getByName( pNames[n] ), UNO_QUERY );
+
+ if( xModel.is() )
+ {
+ // ask model for bindings
+ Reference< XIndexAccess > xBindings(
+ xModel->getBindings(), UNO_QUERY );
+
+ //
+ // Then release them one by one
+ //
+ int nCount = xBindings->getCount();
+ for( int i = nCount-1; i >= 0; i-- )
+ {
+ xModel->getBindings()->remove(xBindings->getByIndex( i ));
+ }
+
+ // ask model for Submissions
+ Reference< XIndexAccess > xSubmissions(
+ xModel->getSubmissions(), UNO_QUERY );
+
+ //
+ // Then release them one by one
+ //
+ nCount = xSubmissions->getCount();
+ for( int i = nCount-1; i >= 0; i-- )
+ {
+ xModel->getSubmissions()->remove(xSubmissions->getByIndex( i ));
+ }
+ }
+ }
+ }
+}