[Libreoffice-commits] core.git: vcl/inc vcl/source
Caolán McNamara
caolanm at redhat.com
Fri Jan 27 20:46:47 UTC 2017
vcl/inc/impgraph.hxx | 1 -
vcl/source/gdi/impgraph.cxx | 32 +++++++++++++-------------------
2 files changed, 13 insertions(+), 20 deletions(-)
New commits:
commit 9bf03203cdc789fb7be58e1b8bc6caa63c6dd09c
Author: Caolán McNamara <caolanm at redhat.com>
Date: Fri Jan 27 15:16:05 2017 +0000
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 at redhat.com>
Tested-by: Caolán McNamara <caolanm at redhat.com>
diff --git a/vcl/inc/impgraph.hxx b/vcl/inc/impgraph.hxx
index 6b4babd..041caf1 100644
--- a/vcl/inc/impgraph.hxx
+++ b/vcl/inc/impgraph.hxx
@@ -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;
diff --git a/vcl/source/gdi/impgraph.cxx b/vcl/source/gdi/impgraph.cxx
index f96a4b2..a82e67a 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 );
More information about the Libreoffice-commits
mailing list