Kaydet (Commit) 9bf03203 authored tarafından Caolán McNamara's avatar Caolán McNamara

remove weirdness of ImpGraphic assignment operator

seems to me that this hackery is to avoid the swapfile
getting pulled out from underneath it during swapin

Change-Id: I6b58d7e31731db8edc4026460beabc667204dcae
Reviewed-on: https://gerrit.libreoffice.org/33620Reviewed-by: 's avatarCaolán McNamara <caolanm@redhat.com>
Tested-by: 's avatarCaolán McNamara <caolanm@redhat.com>
üst f2f6d11e
...@@ -47,7 +47,6 @@ private: ...@@ -47,7 +47,6 @@ private:
GraphicType meType; GraphicType meType;
mutable sal_uLong mnSizeBytes; mutable sal_uLong mnSizeBytes;
bool mbSwapOut; bool mbSwapOut;
bool mbSwapUnderway;
bool mbDummyContext; bool mbDummyContext;
SvgDataPtr maSvgData; SvgDataPtr maSvgData;
css::uno::Sequence<sal_Int8> maPdfData; css::uno::Sequence<sal_Int8> maPdfData;
......
...@@ -101,7 +101,6 @@ ImpGraphic::ImpGraphic() : ...@@ -101,7 +101,6 @@ ImpGraphic::ImpGraphic() :
meType ( GraphicType::NONE ), meType ( GraphicType::NONE ),
mnSizeBytes ( 0UL ), mnSizeBytes ( 0UL ),
mbSwapOut ( false ), mbSwapOut ( false ),
mbSwapUnderway ( false ),
mbDummyContext ( false ) mbDummyContext ( false )
{ {
} }
...@@ -113,7 +112,6 @@ ImpGraphic::ImpGraphic(const ImpGraphic& rImpGraphic) ...@@ -113,7 +112,6 @@ ImpGraphic::ImpGraphic(const ImpGraphic& rImpGraphic)
, meType(rImpGraphic.meType) , meType(rImpGraphic.meType)
, mnSizeBytes(rImpGraphic.mnSizeBytes) , mnSizeBytes(rImpGraphic.mnSizeBytes)
, mbSwapOut(rImpGraphic.mbSwapOut) , mbSwapOut(rImpGraphic.mbSwapOut)
, mbSwapUnderway(false)
, mbDummyContext(rImpGraphic.mbDummyContext) , mbDummyContext(rImpGraphic.mbDummyContext)
, maSvgData(rImpGraphic.maSvgData) , maSvgData(rImpGraphic.maSvgData)
, maPdfData(rImpGraphic.maPdfData) , maPdfData(rImpGraphic.maPdfData)
...@@ -133,7 +131,6 @@ ImpGraphic::ImpGraphic( const Bitmap& rBitmap ) : ...@@ -133,7 +131,6 @@ ImpGraphic::ImpGraphic( const Bitmap& rBitmap ) :
meType ( !rBitmap.IsEmpty() ? GraphicType::Bitmap : GraphicType::NONE ), meType ( !rBitmap.IsEmpty() ? GraphicType::Bitmap : GraphicType::NONE ),
mnSizeBytes ( 0UL ), mnSizeBytes ( 0UL ),
mbSwapOut ( false ), mbSwapOut ( false ),
mbSwapUnderway ( false ),
mbDummyContext ( false ) mbDummyContext ( false )
{ {
} }
...@@ -143,7 +140,6 @@ ImpGraphic::ImpGraphic( const BitmapEx& rBitmapEx ) : ...@@ -143,7 +140,6 @@ ImpGraphic::ImpGraphic( const BitmapEx& rBitmapEx ) :
meType ( !rBitmapEx.IsEmpty() ? GraphicType::Bitmap : GraphicType::NONE ), meType ( !rBitmapEx.IsEmpty() ? GraphicType::Bitmap : GraphicType::NONE ),
mnSizeBytes ( 0UL ), mnSizeBytes ( 0UL ),
mbSwapOut ( false ), mbSwapOut ( false ),
mbSwapUnderway ( false ),
mbDummyContext ( false ) mbDummyContext ( false )
{ {
} }
...@@ -152,7 +148,6 @@ ImpGraphic::ImpGraphic(const SvgDataPtr& rSvgDataPtr) ...@@ -152,7 +148,6 @@ ImpGraphic::ImpGraphic(const SvgDataPtr& rSvgDataPtr)
: meType( rSvgDataPtr.get() ? GraphicType::Bitmap : GraphicType::NONE ), : meType( rSvgDataPtr.get() ? GraphicType::Bitmap : GraphicType::NONE ),
mnSizeBytes( 0UL ), mnSizeBytes( 0UL ),
mbSwapOut( false ), mbSwapOut( false ),
mbSwapUnderway( false ),
mbDummyContext ( false ), mbDummyContext ( false ),
maSvgData(rSvgDataPtr) maSvgData(rSvgDataPtr)
{ {
...@@ -164,7 +159,6 @@ ImpGraphic::ImpGraphic( const Animation& rAnimation ) : ...@@ -164,7 +159,6 @@ ImpGraphic::ImpGraphic( const Animation& rAnimation ) :
meType ( GraphicType::Bitmap ), meType ( GraphicType::Bitmap ),
mnSizeBytes ( 0UL ), mnSizeBytes ( 0UL ),
mbSwapOut ( false ), mbSwapOut ( false ),
mbSwapUnderway ( false ),
mbDummyContext ( false ) mbDummyContext ( false )
{ {
} }
...@@ -174,7 +168,6 @@ ImpGraphic::ImpGraphic( const GDIMetaFile& rMtf ) : ...@@ -174,7 +168,6 @@ ImpGraphic::ImpGraphic( const GDIMetaFile& rMtf ) :
meType ( GraphicType::GdiMetafile ), meType ( GraphicType::GdiMetafile ),
mnSizeBytes ( 0UL ), mnSizeBytes ( 0UL ),
mbSwapOut ( false ), mbSwapOut ( false ),
mbSwapUnderway ( false ),
mbDummyContext ( false ) mbDummyContext ( false )
{ {
} }
...@@ -188,8 +181,7 @@ ImpGraphic& ImpGraphic::operator=( const ImpGraphic& rImpGraphic ) ...@@ -188,8 +181,7 @@ ImpGraphic& ImpGraphic::operator=( const ImpGraphic& rImpGraphic )
{ {
if( &rImpGraphic != this ) if( &rImpGraphic != this )
{ {
if( !mbSwapUnderway ) ImplClear();
ImplClear();
maMetaFile = rImpGraphic.maMetaFile; maMetaFile = rImpGraphic.maMetaFile;
meType = rImpGraphic.meType; meType = rImpGraphic.meType;
...@@ -207,11 +199,8 @@ ImpGraphic& ImpGraphic::operator=( const ImpGraphic& rImpGraphic ) ...@@ -207,11 +199,8 @@ ImpGraphic& ImpGraphic::operator=( const ImpGraphic& rImpGraphic )
maEx = rImpGraphic.maEx; maEx = rImpGraphic.maEx;
} }
if( !mbSwapUnderway ) mbSwapOut = rImpGraphic.mbSwapOut;
{ mpSwapFile = rImpGraphic.mpSwapFile;
mbSwapOut = rImpGraphic.mbSwapOut;
mpSwapFile = rImpGraphic.mpSwapFile;
}
mpGfxLink.reset(); mpGfxLink.reset();
...@@ -1262,15 +1251,22 @@ bool ImpGraphic::ImplSwapIn( SvStream* xIStm ) ...@@ -1262,15 +1251,22 @@ bool ImpGraphic::ImplSwapIn( SvStream* xIStm )
if( !xIStm->GetError() ) if( !xIStm->GetError() )
{ {
mbSwapUnderway = true; //keep the swap file alive, because its quite possibly the backing storage
//for xIStm
std::shared_ptr<ImpSwapFile> xSwapFile(std::move(mpSwapFile));
assert(!mpSwapFile);
bRet = ImplReadEmbedded( *xIStm ); bRet = ImplReadEmbedded( *xIStm );
mbSwapUnderway = false;
//restore ownership of the swap file
mpSwapFile = std::move(xSwapFile);
if (!bRet) if (!bRet)
{ {
//throw away swapfile, etc. //throw away swapfile, etc.
ImplClear(); ImplClear();
} }
mbSwapOut = false; mbSwapOut = false;
} }
} }
...@@ -1278,7 +1274,6 @@ bool ImpGraphic::ImplSwapIn( SvStream* xIStm ) ...@@ -1278,7 +1274,6 @@ bool ImpGraphic::ImplSwapIn( SvStream* xIStm )
return bRet; return bRet;
} }
void ImpGraphic::ImplSetLink( const GfxLink& rGfxLink ) void ImpGraphic::ImplSetLink( const GfxLink& rGfxLink )
{ {
mpGfxLink = o3tl::make_unique<GfxLink>( rGfxLink ); mpGfxLink = o3tl::make_unique<GfxLink>( rGfxLink );
...@@ -1372,8 +1367,7 @@ void ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic ) ...@@ -1372,8 +1367,7 @@ void ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic )
const sal_uLong nStmPos1 = rIStm.Tell(); const sal_uLong nStmPos1 = rIStm.Tell();
sal_uInt32 nTmp; sal_uInt32 nTmp;
if ( !rImpGraphic.mbSwapUnderway ) rImpGraphic.ImplClear();
rImpGraphic.ImplClear();
// read Id // read Id
rIStm.ReadUInt32( nTmp ); rIStm.ReadUInt32( nTmp );
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment