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:
GraphicType meType;
mutable sal_uLong mnSizeBytes;
bool mbSwapOut;
bool mbSwapUnderway;
bool mbDummyContext;
SvgDataPtr maSvgData;
css::uno::Sequence<sal_Int8> maPdfData;
......
......@@ -101,7 +101,6 @@ ImpGraphic::ImpGraphic() :
meType ( GraphicType::NONE ),
mnSizeBytes ( 0UL ),
mbSwapOut ( false ),
mbSwapUnderway ( false ),
mbDummyContext ( false )
{
}
......@@ -113,7 +112,6 @@ ImpGraphic::ImpGraphic(const ImpGraphic& rImpGraphic)
, meType(rImpGraphic.meType)
, mnSizeBytes(rImpGraphic.mnSizeBytes)
, mbSwapOut(rImpGraphic.mbSwapOut)
, mbSwapUnderway(false)
, mbDummyContext(rImpGraphic.mbDummyContext)
, maSvgData(rImpGraphic.maSvgData)
, maPdfData(rImpGraphic.maPdfData)
......@@ -133,7 +131,6 @@ ImpGraphic::ImpGraphic( const Bitmap& rBitmap ) :
meType ( !rBitmap.IsEmpty() ? GraphicType::Bitmap : GraphicType::NONE ),
mnSizeBytes ( 0UL ),
mbSwapOut ( false ),
mbSwapUnderway ( false ),
mbDummyContext ( false )
{
}
......@@ -143,7 +140,6 @@ ImpGraphic::ImpGraphic( const BitmapEx& rBitmapEx ) :
meType ( !rBitmapEx.IsEmpty() ? GraphicType::Bitmap : GraphicType::NONE ),
mnSizeBytes ( 0UL ),
mbSwapOut ( false ),
mbSwapUnderway ( false ),
mbDummyContext ( false )
{
}
......@@ -152,7 +148,6 @@ ImpGraphic::ImpGraphic(const SvgDataPtr& rSvgDataPtr)
: meType( rSvgDataPtr.get() ? GraphicType::Bitmap : GraphicType::NONE ),
mnSizeBytes( 0UL ),
mbSwapOut( false ),
mbSwapUnderway( false ),
mbDummyContext ( false ),
maSvgData(rSvgDataPtr)
{
......@@ -164,7 +159,6 @@ ImpGraphic::ImpGraphic( const Animation& rAnimation ) :
meType ( GraphicType::Bitmap ),
mnSizeBytes ( 0UL ),
mbSwapOut ( false ),
mbSwapUnderway ( false ),
mbDummyContext ( false )
{
}
......@@ -174,7 +168,6 @@ ImpGraphic::ImpGraphic( const GDIMetaFile& rMtf ) :
meType ( GraphicType::GdiMetafile ),
mnSizeBytes ( 0UL ),
mbSwapOut ( false ),
mbSwapUnderway ( false ),
mbDummyContext ( false )
{
}
......@@ -188,8 +181,7 @@ ImpGraphic& ImpGraphic::operator=( const ImpGraphic& rImpGraphic )
{
if( &rImpGraphic != this )
{
if( !mbSwapUnderway )
ImplClear();
ImplClear();
maMetaFile = rImpGraphic.maMetaFile;
meType = rImpGraphic.meType;
......@@ -207,11 +199,8 @@ ImpGraphic& ImpGraphic::operator=( const ImpGraphic& rImpGraphic )
maEx = rImpGraphic.maEx;
}
if( !mbSwapUnderway )
{
mbSwapOut = rImpGraphic.mbSwapOut;
mpSwapFile = rImpGraphic.mpSwapFile;
}
mbSwapOut = rImpGraphic.mbSwapOut;
mpSwapFile = rImpGraphic.mpSwapFile;
mpGfxLink.reset();
......@@ -1262,15 +1251,22 @@ bool ImpGraphic::ImplSwapIn( SvStream* xIStm )
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 );
mbSwapUnderway = false;
//restore ownership of the swap file
mpSwapFile = std::move(xSwapFile);
if (!bRet)
{
//throw away swapfile, etc.
ImplClear();
}
mbSwapOut = false;
}
}
......@@ -1278,7 +1274,6 @@ bool ImpGraphic::ImplSwapIn( SvStream* xIStm )
return bRet;
}
void ImpGraphic::ImplSetLink( const GfxLink& rGfxLink )
{
mpGfxLink = o3tl::make_unique<GfxLink>( rGfxLink );
......@@ -1372,8 +1367,7 @@ void ReadImpGraphic( SvStream& rIStm, ImpGraphic& rImpGraphic )
const sal_uLong nStmPos1 = rIStm.Tell();
sal_uInt32 nTmp;
if ( !rImpGraphic.mbSwapUnderway )
rImpGraphic.ImplClear();
rImpGraphic.ImplClear();
// read Id
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