diff options
author | Armin Le Grand <alg@apache.org> | 2014-01-31 17:42:41 +0000 |
---|---|---|
committer | Armin Le Grand <alg@apache.org> | 2014-01-31 17:42:41 +0000 |
commit | 059b53d8ae713be9c3db23481768888e74e39586 (patch) | |
tree | 9c2dd3e6dcb9e74f8b7f4726677c74d08f9455f2 /sw | |
parent | 9957d5854dcc65db37f0631c19e3421df1311089 (diff) |
i123914 Use an own hold on the newly created SwDoc when a call to SetTmpDocShell(NULL) is needed
Notes
Notes:
prefer: 190ee22a5161626b61a953556c5888e330e143b6
Diffstat (limited to 'sw')
-rw-r--r-- | sw/source/core/doc/docnew.cxx | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/sw/source/core/doc/docnew.cxx b/sw/source/core/doc/docnew.cxx index 7682e58be26d..ab3bd935203c 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; } |