[Libreoffice-commits] .: Branch 'libreoffice-3-4' - sw/source

Caolán McNamara caolan at kemper.freedesktop.org
Wed May 25 05:27:48 PDT 2011


 sw/source/core/doc/docnew.cxx |   31 +++++++++++++++++++------------
 1 file changed, 19 insertions(+), 12 deletions(-)

New commits:
commit c3f1dc1148593224aa77b1f4bdc3db1804adb07a
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed May 25 13:20:11 2011 +0100

    Resolves: fdo#35937 temp ole docshell on dtor deletes SwDoc on 0 refcount
    
    copy of ole objects creates a temp docshell, whose dtor on 0 ref count deletes
    the SwDoc handle. So add an acquire/release pair.
    (cherry picked from commit fb5c25294efd2ef9138df61e82cd438ff07f4bf1)

diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx
index 0527ab9..6cc62a1 100644
--- a/sw/source/core/doc/docnew.cxx
+++ b/sw/source/core/doc/docnew.cxx
@@ -1048,6 +1048,7 @@ void SwDoc::InitTOXTypes()
 SfxObjectShell* SwDoc::CreateCopy(bool bCallInitNew ) const
 {
     SwDoc* pRet = new SwDoc;
+
     //copy settings
     sal_uInt16 aRangeOfDefaults[] = {
         RES_FRMATR_BEGIN, RES_FRMATR_END-1,
@@ -1058,22 +1059,24 @@ SfxObjectShell* SwDoc::CreateCopy(bool bCallInitNew ) const
         0
     };
 
-    SfxItemSet aNewDefaults( pRet->GetAttrPool(), aRangeOfDefaults );
-
-    sal_uInt16 nWhich;
-    sal_uInt16 nRange = 0;
-    while( aRangeOfDefaults[nRange] != 0)
     {
-        for( nWhich = aRangeOfDefaults[nRange]; nWhich < aRangeOfDefaults[nRange + 1]; ++nWhich )
+        SfxItemSet aNewDefaults( pRet->GetAttrPool(), aRangeOfDefaults );
+
+        sal_uInt16 nWhich;
+        sal_uInt16 nRange = 0;
+        while( aRangeOfDefaults[nRange] != 0)
         {
-            const SfxPoolItem& rSourceAttr = mpAttrPool->GetDefaultItem( nWhich );
-            if( rSourceAttr != pRet->mpAttrPool->GetDefaultItem( nWhich ) )
-                aNewDefaults.Put( rSourceAttr );
+            for( nWhich = aRangeOfDefaults[nRange]; nWhich < aRangeOfDefaults[nRange + 1]; ++nWhich )
+            {
+                const SfxPoolItem& rSourceAttr = mpAttrPool->GetDefaultItem( nWhich );
+                if( rSourceAttr != pRet->mpAttrPool->GetDefaultItem( nWhich ) )
+                    aNewDefaults.Put( rSourceAttr );
+            }
+            nRange += 2;
         }
-        nRange += 2;
+        if( aNewDefaults.Count() )
+            pRet->SetDefault( aNewDefaults );
     }
-    if( aNewDefaults.Count() )
-        pRet->SetDefault( aNewDefaults );
 
     pRet->n32DummyCompatabilityOptions1 = n32DummyCompatabilityOptions1;
     pRet->n32DummyCompatabilityOptions2 = n32DummyCompatabilityOptions2;
@@ -1117,12 +1120,16 @@ SfxObjectShell* SwDoc::CreateCopy(bool bCallInitNew ) const
         pRetShell->DoInitNew();
     }
 
+    pRet->acquire();
+
     //copy content 
     pRet->Paste( *this );
 
     // remove the temporary shell if it is there as it was done before
     pRet->SetTmpDocShell( (SfxObjectShell*)NULL );
 
+    pRet->release();
+
     return pRetShell;
 }
 


More information about the Libreoffice-commits mailing list