summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndrzej Hunt <andrzej.hunt@collabora.com>2014-07-30 15:16:49 +0200
committerMihai Varga <mihai.mv13@gmail.com>2014-07-31 15:28:02 +0300
commitdddab507be78c4a1d1607d7fa3c3038274257022 (patch)
treeb78f24198d9c6846dff9f0f728837c33fea0883f
parentAvoid possible memory leaks in case of exceptions (diff)
downloadcore-dddab507be78c4a1d1607d7fa3c3038274257022.tar.gz
core-dddab507be78c4a1d1607d7fa3c3038274257022.zip
Use SolarMutexGuard instead of pairs of Acquire/ReleaseSolarMutex
Change-Id: I7ff41dd932fd9860dff944b3bf8ff5bdc230ae5d
-rw-r--r--desktop/source/lib/init.cxx99
1 files changed, 46 insertions, 53 deletions
diff --git a/desktop/source/lib/init.cxx b/desktop/source/lib/init.cxx
index 138b8f5dd3b5..bc38cc2720be 100644
--- a/desktop/source/lib/init.cxx
+++ b/desktop/source/lib/init.cxx
@@ -466,11 +466,8 @@ static void doc_setPart(LibreOfficeKitDocument* pThis, int nPart)
return;
}
- Application::AcquireSolarMutex(1);
- {
- pDoc->setPart( nPart );
- }
- Application::ReleaseSolarMutex();
+ SolarMutexGuard aGuard;
+ pDoc->setPart( nPart );
}
static char* doc_getPartName(LibreOfficeKitDocument* pThis, int nPart)
@@ -504,31 +501,29 @@ static void doc_setPartMode(LibreOfficeKitDocument* pThis,
return;
}
- Application::AcquireSolarMutex(1);
+ SolarMutexGuard aGuard;
+
+ int nCurrentPart = pDoc->getPart();
+
+ pDoc->setPartMode(ePartMode);
+
+ // We need to make sure the internal state is updated, just changing the mode
+ // might not update the relevant shells (i.e. impress will keep rendering the
+ // previous mode unless we do this).
+ // TODO: we might want to do this within the relevant components rather than
+ // here, but that's also dependent on how we implement embedded object
+ // rendering I guess?
+ // TODO: we could be clever and e.g. set to 0 when we change to/from
+ // embedded object mode, and not when changing between slide/notes/combined
+ // modes?
+ if ( nCurrentPart < pDoc->getParts() )
{
- int nCurrentPart = pDoc->getPart();
-
- pDoc->setPartMode(ePartMode);
-
- // We need to make sure the internal state is updated, just changing the mode
- // might not update the relevant shells (i.e. impress will keep rendering the
- // previous mode unless we do this).
- // TODO: we might want to do this within the relevant components rather than
- // here, but that's also dependent on how we implement embedded object
- // rendering I guess?
- // TODO: we could be clever and e.g. set to 0 when we change to/from
- // embedded object mode, and not when changing between slide/notes/combined
- // modes?
- if ( nCurrentPart < pDoc->getParts() )
- {
- pDoc->setPart( nCurrentPart );
- }
- else
- {
- pDoc->setPart( 0 );
- }
+ pDoc->setPart( nCurrentPart );
+ }
+ else
+ {
+ pDoc->setPart( 0 );
}
- Application::ReleaseSolarMutex();
}
void doc_paintTile (LibreOfficeKitDocument* pThis,
@@ -550,38 +545,36 @@ void doc_paintTile (LibreOfficeKitDocument* pThis,
return;
}
- Application::AcquireSolarMutex(1);
- {
+ SolarMutexGuard aGuard;
+
#if defined(UNX) && !defined(MACOSX) && !defined(ENABLE_HEADLESS)
- ImplSVData* pSVData = ImplGetSVData();
- SvpSalInstance* pSalInstance = static_cast< SvpSalInstance* >(pSVData->mpDefInst);
- pSalInstance->setBitCountFormatMapping( 32, ::basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA );
+ ImplSVData* pSVData = ImplGetSVData();
+ SvpSalInstance* pSalInstance = static_cast< SvpSalInstance* >(pSVData->mpDefInst);
+ pSalInstance->setBitCountFormatMapping( 32, ::basebmp::FORMAT_THIRTYTWO_BIT_TC_MASK_RGBA );
- VirtualDevice aDevice(0, (sal_uInt16)32);
- boost::shared_array< sal_uInt8 > aBuffer( pBuffer, NoDelete< sal_uInt8 >() );
- aDevice.SetOutputSizePixelScaleOffsetAndBuffer(
- Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(),
- aBuffer, true );
+ VirtualDevice aDevice(0, (sal_uInt16)32);
+ boost::shared_array< sal_uInt8 > aBuffer( pBuffer, NoDelete< sal_uInt8 >() );
+ aDevice.SetOutputSizePixelScaleOffsetAndBuffer(
+ Size(nCanvasWidth, nCanvasHeight), Fraction(1.0), Point(),
+ aBuffer, true );
- pDoc->paintTile(aDevice, nCanvasWidth, nCanvasHeight,
- nTilePosX, nTilePosY, nTileWidth, nTileHeight);
+ pDoc->paintTile(aDevice, nCanvasWidth, nCanvasHeight,
+ nTilePosX, nTilePosY, nTileWidth, nTileHeight);
- SvpSalVirtualDevice* pSalDev = static_cast< SvpSalVirtualDevice* >(aDevice.getSalVirtualDevice());
- basebmp::BitmapDeviceSharedPtr pBmpDev = pSalDev->getBitmapDevice();
+ SvpSalVirtualDevice* pSalDev = static_cast< SvpSalVirtualDevice* >(aDevice.getSalVirtualDevice());
+ basebmp::BitmapDeviceSharedPtr pBmpDev = pSalDev->getBitmapDevice();
- *pRowStride = pBmpDev->getScanlineStride();
+ *pRowStride = pBmpDev->getScanlineStride();
#else
- (void) pBuffer;
- (void) nCanvasWidth;
- (void) nCanvasHeight;
- (void) pRowStride;
- (void) nTilePosX;
- (void) nTilePosY;
- (void) nTileWidth;
- (void) nTileHeight;
+ (void) pBuffer;
+ (void) nCanvasWidth;
+ (void) nCanvasHeight;
+ (void) pRowStride;
+ (void) nTilePosX;
+ (void) nTilePosY;
+ (void) nTileWidth;
+ (void) nTileHeight;
#endif
- }
- Application::ReleaseSolarMutex();
}
static void doc_getDocumentSize(LibreOfficeKitDocument* pThis,