summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embeddedobj/source/inc/oleembobj.hxx7
-rw-r--r--embeddedobj/source/msole/oleembed.cxx8
-rw-r--r--embeddedobj/source/msole/olemisc.cxx15
-rw-r--r--embeddedobj/source/msole/olepersist.cxx25
-rw-r--r--embeddedobj/source/msole/olevisual.cxx4
5 files changed, 33 insertions, 26 deletions
diff --git a/embeddedobj/source/inc/oleembobj.hxx b/embeddedobj/source/inc/oleembobj.hxx
index 087a3c829527..62fea5d35702 100644
--- a/embeddedobj/source/inc/oleembobj.hxx
+++ b/embeddedobj/source/inc/oleembobj.hxx
@@ -217,7 +217,7 @@ protected:
css::uno::Reference< css::io::XStream > GetNewFilledTempStream_Impl(
const css::uno::Reference< css::io::XInputStream >& xInStream );
#ifdef _WIN32
- void SwitchComponentToRunningState_Impl();
+ void SwitchComponentToRunningState_Impl(osl::ResettableMutexGuard& guard);
#endif
void MakeEventListenerNotification_Impl( const OUString& aEventName );
#ifdef _WIN32
@@ -231,7 +231,7 @@ protected:
const css::uno::Sequence< css::embed::VerbDescriptor >& aVerbList );
#endif
- void Dispose();
+ void Dispose(osl::ResettableMutexGuard* guard = nullptr);
void SwitchOwnPersistence(
const css::uno::Reference< css::embed::XStorage >& xNewParentStorage,
@@ -242,7 +242,7 @@ protected:
const css::uno::Reference< css::embed::XStorage >& xNewParentStorage,
const OUString& aNewName );
- void GetRidOfComponent();
+ void GetRidOfComponent(osl::ResettableMutexGuard* guard);
/// @throws css::uno::Exception
void StoreToLocation_Impl(
@@ -272,6 +272,7 @@ protected:
css::uno::Reference< css::io::XStream > TryToRetrieveCachedVisualRepresentation_Impl(
const css::uno::Reference< css::io::XStream >& xStream,
+ osl::ResettableMutexGuard& rGuard,
bool bAllowRepair50 = false )
noexcept;
#ifdef _WIN32
diff --git a/embeddedobj/source/msole/oleembed.cxx b/embeddedobj/source/msole/oleembed.cxx
index 835ef9cd4885..f61d8056fdeb 100644
--- a/embeddedobj/source/msole/oleembed.cxx
+++ b/embeddedobj/source/msole/oleembed.cxx
@@ -66,7 +66,7 @@ using namespace ::com::sun::star;
#ifdef _WIN32
-void OleEmbeddedObject::SwitchComponentToRunningState_Impl()
+void OleEmbeddedObject::SwitchComponentToRunningState_Impl(osl::ResettableMutexGuard& guard)
{
if ( !m_pOleComponent )
{
@@ -78,12 +78,12 @@ void OleEmbeddedObject::SwitchComponentToRunningState_Impl()
}
catch( const embed::UnreachableStateException& )
{
- GetRidOfComponent();
+ GetRidOfComponent(&guard);
throw;
}
catch( const embed::WrongStateException& )
{
- GetRidOfComponent();
+ GetRidOfComponent(&guard);
throw;
}
}
@@ -518,7 +518,7 @@ void SAL_CALL OleEmbeddedObject::changeState( sal_Int32 nNewState )
// it can be created during loading to detect type of object
CreateOleComponentAndLoad_Impl( m_pOleComponent );
- SwitchComponentToRunningState_Impl();
+ SwitchComponentToRunningState_Impl(aGuard);
m_nObjectState = embed::EmbedStates::RUNNING;
aGuard.clear();
StateChangeNotification_Impl( false, nOldState, m_nObjectState );
diff --git a/embeddedobj/source/msole/olemisc.cxx b/embeddedobj/source/msole/olemisc.cxx
index efed07fa187d..13fc558a529e 100644
--- a/embeddedobj/source/msole/olemisc.cxx
+++ b/embeddedobj/source/msole/olemisc.cxx
@@ -221,7 +221,7 @@ void OleEmbeddedObject::StateChangeNotification_Impl( bool bBeforeChange, sal_In
}
#endif
-void OleEmbeddedObject::GetRidOfComponent()
+void OleEmbeddedObject::GetRidOfComponent(osl::ResettableMutexGuard* guard)
{
#ifdef _WIN32
if ( m_pOleComponent )
@@ -232,6 +232,9 @@ void OleEmbeddedObject::GetRidOfComponent()
m_pOleComponent->removeCloseListener( m_xClosePreventer );
try
{
+ std::optional<osl::ResettableMutexGuardScopedReleaser> oReleaser;
+ if (guard)
+ oReleaser.emplace(*guard);
m_pOleComponent->close( false );
}
catch( const uno::Exception& )
@@ -245,11 +248,13 @@ void OleEmbeddedObject::GetRidOfComponent()
m_pOleComponent->disconnectEmbeddedObject();
m_pOleComponent.clear();
}
+#else
+ (void)guard;
#endif
}
-void OleEmbeddedObject::Dispose()
+void OleEmbeddedObject::Dispose(osl::ResettableMutexGuard* guard)
{
if ( m_pInterfaceContainer )
{
@@ -266,7 +271,7 @@ void OleEmbeddedObject::Dispose()
if ( m_pOleComponent )
try {
- GetRidOfComponent();
+ GetRidOfComponent(guard);
} catch( const uno::Exception& )
{
m_bDisposed = true;
@@ -449,7 +454,7 @@ void SAL_CALL OleEmbeddedObject::close( sal_Bool bDeliverOwnership )
}
// end wrapping related part ====================
- ::osl::MutexGuard aGuard( m_aMutex );
+ osl::ResettableMutexGuard aGuard(m_aMutex);
if ( m_bDisposed )
throw lang::DisposedException(); // TODO
@@ -495,7 +500,7 @@ void SAL_CALL OleEmbeddedObject::close( sal_Bool bDeliverOwnership )
}
}
- Dispose();
+ Dispose(&aGuard);
}
diff --git a/embeddedobj/source/msole/olepersist.cxx b/embeddedobj/source/msole/olepersist.cxx
index 486c636aee95..65811c31a331 100644
--- a/embeddedobj/source/msole/olepersist.cxx
+++ b/embeddedobj/source/msole/olepersist.cxx
@@ -594,6 +594,7 @@ bool OleEmbeddedObject::HasVisReplInStream()
uno::Reference< io::XStream > OleEmbeddedObject::TryToRetrieveCachedVisualRepresentation_Impl(
const uno::Reference< io::XStream >& xStream,
+ osl::ResettableMutexGuard& rGuard,
bool bAllowToRepair50 )
noexcept
{
@@ -697,7 +698,7 @@ uno::Reference< io::XStream > OleEmbeddedObject::TryToRetrieveCachedVisualRepres
#ifdef _WIN32
// retry to create the component after recovering
- GetRidOfComponent();
+ GetRidOfComponent(&rGuard);
try
{
@@ -706,12 +707,12 @@ uno::Reference< io::XStream > OleEmbeddedObject::TryToRetrieveCachedVisualRepres
}
catch( const uno::Exception& )
{
- GetRidOfComponent();
+ GetRidOfComponent(&rGuard);
}
#endif
}
- xResult = TryToRetrieveCachedVisualRepresentation_Impl( xStream );
+ xResult = TryToRetrieveCachedVisualRepresentation_Impl( xStream, rGuard );
}
}
}
@@ -1173,7 +1174,7 @@ void OleEmbeddedObject::StoreToLocation_Impl(
// is not changed by StoreTo action
uno::Reference< io::XStream > xTmpCVRepresentation =
- TryToRetrieveCachedVisualRepresentation_Impl( xTargetStream );
+ TryToRetrieveCachedVisualRepresentation_Impl( xTargetStream, rGuard );
// the locally retrieved representation is always preferable
if ( xTmpCVRepresentation.is() )
@@ -1204,7 +1205,7 @@ void OleEmbeddedObject::StoreToLocation_Impl(
if ( bStoreVis )
{
if ( !xCachedVisualRepresentation.is() )
- xCachedVisualRepresentation = TryToRetrieveCachedVisualRepresentation_Impl( xTargetStream );
+ xCachedVisualRepresentation = TryToRetrieveCachedVisualRepresentation_Impl( xTargetStream, rGuard );
SAL_WARN_IF( !xCachedVisualRepresentation.is(), "embeddedobj.ole", "No representation is available!" );
@@ -1228,7 +1229,7 @@ void OleEmbeddedObject::StoreToLocation_Impl(
{
// the removed representation could be cached by this method
if ( !xCachedVisualRepresentation.is() )
- xCachedVisualRepresentation = TryToRetrieveCachedVisualRepresentation_Impl( xTargetStream );
+ xCachedVisualRepresentation = TryToRetrieveCachedVisualRepresentation_Impl( xTargetStream, rGuard );
if (!m_bStreamReadOnly)
RemoveVisualCache_Impl(xTargetStream);
@@ -1294,7 +1295,7 @@ void SAL_CALL OleEmbeddedObject::setPersistentEntry(
// the only exception is object initialized from a stream,
// the class ID will be detected from the stream
- ::osl::MutexGuard aGuard( m_aMutex );
+ osl::ResettableMutexGuard aGuard( m_aMutex );
if ( m_bDisposed )
throw lang::DisposedException(); // TODO
@@ -1378,7 +1379,7 @@ void SAL_CALL OleEmbeddedObject::setPersistentEntry(
{
// TODO/LATER: detect classID of the object if possible
// means that the object inprocess server could not be successfully instantiated
- GetRidOfComponent();
+ GetRidOfComponent(&aGuard);
}
m_nObjectState = embed::EmbedStates::LOADED;
@@ -1753,14 +1754,14 @@ void SAL_CALL OleEmbeddedObject::storeOwn()
InsertVisualCache_Impl( m_xObjectStream, m_xCachedVisualRepresentation );
else
{
- m_xCachedVisualRepresentation = TryToRetrieveCachedVisualRepresentation_Impl( m_xObjectStream );
+ m_xCachedVisualRepresentation = TryToRetrieveCachedVisualRepresentation_Impl( m_xObjectStream, aGuard );
SAL_WARN_IF( !m_xCachedVisualRepresentation.is(), "embeddedobj.ole", "No representation is available!" );
}
}
else
{
if ( !m_xCachedVisualRepresentation.is() )
- m_xCachedVisualRepresentation = TryToRetrieveCachedVisualRepresentation_Impl( m_xObjectStream );
+ m_xCachedVisualRepresentation = TryToRetrieveCachedVisualRepresentation_Impl( m_xObjectStream, aGuard );
RemoveVisualCache_Impl( m_xObjectStream );
}
@@ -1875,7 +1876,7 @@ void SAL_CALL OleEmbeddedObject::breakLink( const uno::Reference< embed::XStorag
}
// end wrapping related part ====================
- ::osl::MutexGuard aGuard( m_aMutex );
+ osl::ResettableMutexGuard aGuard( m_aMutex );
if ( m_bDisposed )
throw lang::DisposedException(); // TODO
@@ -1927,7 +1928,7 @@ void SAL_CALL OleEmbeddedObject::breakLink( const uno::Reference< embed::XStorag
}
try {
- GetRidOfComponent();
+ GetRidOfComponent(&aGuard);
}
catch (const uno::Exception&)
{
diff --git a/embeddedobj/source/msole/olevisual.cxx b/embeddedobj/source/msole/olevisual.cxx
index 83dc0903e0bb..539933278e45 100644
--- a/embeddedobj/source/msole/olevisual.cxx
+++ b/embeddedobj/source/msole/olevisual.cxx
@@ -346,7 +346,7 @@ embed::VisualRepresentation SAL_CALL OleEmbeddedObject::getPreferredVisualRepres
if ( !m_xCachedVisualRepresentation.is() && ( !m_bVisReplInitialized || m_bVisReplInStream )
&& m_nObjectState == embed::EmbedStates::LOADED )
{
- m_xCachedVisualRepresentation = TryToRetrieveCachedVisualRepresentation_Impl( m_xObjectStream, true );
+ m_xCachedVisualRepresentation = TryToRetrieveCachedVisualRepresentation_Impl( m_xObjectStream, aGuard, true );
SetVisReplInStream( m_xCachedVisualRepresentation.is() );
}
@@ -388,7 +388,7 @@ embed::VisualRepresentation SAL_CALL OleEmbeddedObject::getPreferredVisualRepres
// the cache is used only as a fallback if object is not in loaded state
if ( !m_xCachedVisualRepresentation.is() && ( !m_bVisReplInitialized || m_bVisReplInStream ) )
{
- m_xCachedVisualRepresentation = TryToRetrieveCachedVisualRepresentation_Impl( m_xObjectStream );
+ m_xCachedVisualRepresentation = TryToRetrieveCachedVisualRepresentation_Impl( m_xObjectStream, aGuard );
SetVisReplInStream( m_xCachedVisualRepresentation.is() );
}