[Libreoffice-commits] core.git: Branch 'aoo/trunk' - sw/source

Armin Le Grand alg at apache.org
Fri Jan 31 10:08:30 PST 2014


 sw/source/core/doc/docnew.cxx |   20 +++++++++++++++++++-
 1 file changed, 19 insertions(+), 1 deletion(-)

New commits:
commit 059b53d8ae713be9c3db23481768888e74e39586
Author: Armin Le Grand <alg at apache.org>
Date:   Fri Jan 31 17:42:41 2014 +0000

    i123914 Use an own hold on the newly created SwDoc when a call to SetTmpDocShell(NULL) is needed

diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 7682e58..ab3bd93 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -1202,7 +1202,25 @@ SfxObjectShell* SwDoc::CreateCopy(bool bCallInitNew ) const
     pRet->Paste( *this );
 
     // remove the temporary shell if it is there as it was done before
-    pRet->SetTmpDocShell( (SfxObjectShell*)NULL );
+    if(pRet->GetTmpDocShell())
+    {
+        // #123914# If we get here, SwOLENode::MakeCopy had to create a temporary
+        // SwDocShell to have a SvPersist as a target for the OLE data to be copied.
+        // It is reset by a call to SetTmpDocShell(NULL), but in this case here
+        // there is no other ref holder to the just cloned SwDoc. Thus - to prevent
+        // it's immediate deletion - it is required to hold a fercunt to it during
+        // the SetTmpDocShell call. This can be done with an instance of a class
+        // holding a SwDoc, but most simple using acquire/release on the SwDoc
+        // (as long as these are public, I was surprised. Also probably not
+        // guaranteed for the future is that the release call does not delete the
+        // SwDoc it gets called at, but currently works like this).
+        pRet->acquire();
+        pRet->SetTmpDocShell((SfxObjectShell*)NULL);
+        pRet->release();
+    }
+
+    // remove the temporary shell if it is there as it was done before
+    // pRet->SetTmpDocShell( (SfxObjectShell*)NULL );
 
     return pRetShell;
 }


More information about the Libreoffice-commits mailing list