diff options
author | Zolnai Tamás <tamas.zolnai@collabora.com> | 2014-10-19 18:25:23 +0200 |
---|---|---|
committer | Zolnai Tamás <tamas.zolnai@collabora.com> | 2014-11-07 10:45:06 +0100 |
commit | 29413c3ae9dfe99048580710f0b1d95c9663d508 (patch) | |
tree | bbdda483bea2820e7e3f318f24239191e76ba828 /svtools | |
parent | fe272a757b60fdf267539102b0a9927f68e1526a (diff) |
Avoid using null pointer as a special indicator
When ImpGraphic::ImplSwapOut() is called with null
pointer it was assumed that it is becase the graphic is
a link and so we don't need to swap out it actually (we can
load it anytime using the link), only clear the graphic's
internal data.
The problem with that it can happen that ImplSwapOut()
is called with null pointer accidentally on a non-link
graphic object which leads to that we loose the graphic.
Seems more robust to use an explicit indicator
(GRFMGR_AUTOSWAPSTREAM_LINK) for links swapout.
indicator
Change-Id: Icf31524a192c7866278ba6a13eb85648aa69f554
Diffstat (limited to 'svtools')
-rw-r--r-- | svtools/source/graphic/grfmgr.cxx | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/svtools/source/graphic/grfmgr.cxx b/svtools/source/graphic/grfmgr.cxx index 6c7c93326529..f02b185b4bda 100644 --- a/svtools/source/graphic/grfmgr.cxx +++ b/svtools/source/graphic/grfmgr.cxx @@ -1099,7 +1099,16 @@ bool GraphicObject::SwapOut() bool GraphicObject::SwapOut( SvStream* pOStm ) { - const bool bRet = !mbAutoSwapped && maGraphic.SwapOut( pOStm ); + bool bRet = !mbAutoSwapped; + // swap out as a link + if( pOStm == GRFMGR_AUTOSWAPSTREAM_LINK ) + { + maGraphic.SwapOutAsLink(); + } + else + { + bRet = bRet && maGraphic.SwapOut( pOStm ); + } if( bRet && mpMgr ) mpMgr->ImplGraphicObjectWasSwappedOut( *this ); @@ -1158,7 +1167,7 @@ IMPL_LINK_NOARG(GraphicObject, ImplAutoSwapOutHdl) if( GRFMGR_AUTOSWAPSTREAM_NONE != pStream ) { if( GRFMGR_AUTOSWAPSTREAM_LINK == pStream ) - mbAutoSwapped = SwapOut( NULL ); + mbAutoSwapped = SwapOut( GRFMGR_AUTOSWAPSTREAM_LINK ); else { if( GRFMGR_AUTOSWAPSTREAM_TEMP == pStream ) |