summaryrefslogtreecommitdiff
path: root/vcl/source
diff options
context:
space:
mode:
authorCaolán McNamara <caolanm@redhat.com>2017-01-27 15:16:05 +0000
committerCaolán McNamara <caolanm@redhat.com>2017-01-27 20:46:11 +0000
commit9bf03203cdc789fb7be58e1b8bc6caa63c6dd09c (patch)
treee9e43606227d19be4f8adda6856d87f66e662028 /vcl/source
parentf2f6d11e35cdd09291e730429d6c876532f34328 (diff)
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/33620 Reviewed-by: Caolán McNamara <caolanm@redhat.com> Tested-by: Caolán McNamara <caolanm@redhat.com>
Diffstat (limited to 'vcl/source')
-rw-r--r--vcl/source/gdi/impgraph.cxx32
1 files changed, 13 insertions, 19 deletions
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index f96a4b28e305..a82e67a57e02 100644
--- a/vcl/source/gdi/impgraph.cxx
+++ b/vcl/source/gdi/impgraph.cxx
@@ -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 );