summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--dtrans/source/win32/clipb/WinClipbImpl.cxx30
-rw-r--r--dtrans/source/win32/clipb/WinClipbImpl.hxx7
-rw-r--r--dtrans/source/win32/clipb/WinClipboard.cxx19
-rw-r--r--dtrans/source/win32/clipb/WinClipboard.hxx13
4 files changed, 52 insertions, 17 deletions
diff --git a/dtrans/source/win32/clipb/WinClipbImpl.cxx b/dtrans/source/win32/clipb/WinClipbImpl.cxx
index 24d9a54716d5..dd929602c624 100644
--- a/dtrans/source/win32/clipb/WinClipbImpl.cxx
+++ b/dtrans/source/win32/clipb/WinClipbImpl.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: WinClipbImpl.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: tra $ $Date: 2001-03-06 13:53:37 $
+ * last change: $Author: tra $ $Date: 2001-03-07 11:23:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -178,7 +178,8 @@ Reference< XTransferable > SAL_CALL CWinClipbImpl::getContents( ) throw( Runtime
//------------------------------------------------------------------------
void SAL_CALL CWinClipbImpl::setContents( const Reference< XTransferable >& xTransferable,
- const Reference< XClipboardOwner >& xClipboardOwner )
+ const Reference< XClipboardOwner >& xClipboardOwner,
+ ClearableMutexGuard& aGuard )
throw( RuntimeException )
{
CDTransObjFactory objFactory;
@@ -195,6 +196,13 @@ void SAL_CALL CWinClipbImpl::setContents( const Reference< XTransferable >& xTra
// used to differentiate in ClipboardContentChanged handler
m_bSelfTriggered = sal_True;
+ // block other threads via a condition
+ // release the mutex before calling into
+ // windows, because another thread can't
+ // do it
+ m_pWinClipboard->m_aCondition.reset( );
+ aGuard.clear( );
+
MTASetClipboard( pIDataObj );
}
@@ -267,10 +275,17 @@ void CALLBACK CWinClipbImpl::onClipboardContentChanged( void )
Reference< XTransferable > xClipbContent;
Reference< XClipboardOwner > xClipbOwner;
- if ( s_pCWinClipbImpl->m_rOldClipbContent.is( ) && s_pCWinClipbImpl->m_rOldClipbOwner.is( ) )
+ if ( s_pCWinClipbImpl->m_rOldClipbContent.is( ) &&
+ s_pCWinClipbImpl->m_rOldClipbOwner.is( ) )
{
+ // release the condition because of expected callbacks
+ // to the clipboard service (remeber: the mutex is already
+ // released)
+ s_pCWinClipbImpl->m_pWinClipboard->m_aCondition.set( );
+
s_pCWinClipbImpl->m_rOldClipbOwner->lostOwnership(
s_pCWinClipbImpl->m_pWinClipboard, s_pCWinClipbImpl->m_rOldClipbContent );
+
s_pCWinClipbImpl->m_rOldClipbOwner = Reference< XClipboardOwner >( );
s_pCWinClipbImpl->m_rOldClipbContent = Reference< XTransferable >( );
}
@@ -285,13 +300,16 @@ void CALLBACK CWinClipbImpl::onClipboardContentChanged( void )
s_pCWinClipbImpl->m_rCurrentClipbOwner = Reference< XClipboardOwner >( );
s_pCWinClipbImpl->m_rCurrentClipbContent = Reference< XTransferable >( );
- // release the mutex, so that a getContent call would succeed
- aGuard.clear( );
+ // release the condition because of expected callbacks
+ // to the clipboard service (remeber: the mutex is already
+ // released)
+ s_pCWinClipbImpl->m_pWinClipboard->m_aCondition.set( );
// notify the old ClipboardOwner
xClipbOwner->lostOwnership( s_pCWinClipbImpl->m_pWinClipboard, xClipbContent );
}
+ s_pCWinClipbImpl->m_pWinClipboard->m_aCondition.set( );
s_pCWinClipbImpl->m_bSelfTriggered = sal_False;
// reassocition to instance through static member
diff --git a/dtrans/source/win32/clipb/WinClipbImpl.hxx b/dtrans/source/win32/clipb/WinClipbImpl.hxx
index 51641d4136c9..f29fcead6b9b 100644
--- a/dtrans/source/win32/clipb/WinClipbImpl.hxx
+++ b/dtrans/source/win32/clipb/WinClipbImpl.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: WinClipbImpl.hxx,v $
*
- * $Revision: 1.2 $
+ * $Revision: 1.3 $
*
- * last change: $Author: tra $ $Date: 2001-03-06 12:27:02 $
+ * last change: $Author: tra $ $Date: 2001-03-07 11:23:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -109,7 +109,8 @@ protected:
throw( ::com::sun::star::uno::RuntimeException );
void SAL_CALL setContents( const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable >& xTransferable,
- const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardOwner >& xClipboardOwner )
+ const ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::clipboard::XClipboardOwner >& xClipboardOwner,
+ osl::ClearableMutexGuard& aGuard )
throw( ::com::sun::star::uno::RuntimeException );
::rtl::OUString SAL_CALL getName( ) throw( ::com::sun::star::uno::RuntimeException );
diff --git a/dtrans/source/win32/clipb/WinClipboard.cxx b/dtrans/source/win32/clipb/WinClipboard.cxx
index 80283806ed89..42ba54867892 100644
--- a/dtrans/source/win32/clipb/WinClipboard.cxx
+++ b/dtrans/source/win32/clipb/WinClipboard.cxx
@@ -2,9 +2,9 @@
*
* $RCSfile: WinClipboard.cxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: tra $ $Date: 2001-03-06 13:55:02 $
+ * last change: $Author: tra $ $Date: 2001-03-07 11:23:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -121,6 +121,7 @@ CWinClipboard::CWinClipboard( const Reference< XMultiServiceFactory >& rServiceM
WeakComponentImplHelper4< XClipboardEx, XFlushableClipboard, XClipboardNotifier, XServiceInfo >( m_aCbListenerMutex ),
m_SrvMgr( rServiceManager )
{
+ m_aCondition.set( );
m_pImpl.reset( new CWinClipbImpl( aClipboardName, this ) );
}
@@ -139,6 +140,8 @@ CWinClipboard::CWinClipboard( const Reference< XMultiServiceFactory >& rServiceM
Reference< XTransferable > SAL_CALL CWinClipboard::getContents( ) throw( RuntimeException )
{
+ m_aCondition.wait( );
+
MutexGuard aGuard( m_aMutex );
OSL_ENSURE( !rBHelper.bDisposed, "Object is already disposed" );
@@ -153,10 +156,12 @@ void SAL_CALL CWinClipboard::setContents( const Reference< XTransferable >& xTra
const Reference< XClipboardOwner >& xClipboardOwner )
throw( RuntimeException )
{
- MutexGuard aGuard( m_aMutex );
+ m_aCondition.wait( );
+
+ ClearableMutexGuard aGuard( m_aMutex );
OSL_ENSURE( !rBHelper.bDisposed, "Object is already disposed" );
- m_pImpl->setContents( xTransferable, xClipboardOwner );
+ m_pImpl->setContents( xTransferable, xClipboardOwner, aGuard );
}
//------------------------------------------------------------------------
@@ -174,6 +179,8 @@ OUString SAL_CALL CWinClipboard::getName( ) throw( RuntimeException )
void SAL_CALL CWinClipboard::flushClipboard( ) throw( RuntimeException )
{
+ m_aCondition.wait( );
+
MutexGuard aGuard( m_aMutex );
OSL_ENSURE( !rBHelper.bDisposed, "Object is already disposed" );
@@ -200,6 +207,8 @@ sal_Int8 SAL_CALL CWinClipboard::getRenderingCapabilities( ) throw( RuntimeExce
void SAL_CALL CWinClipboard::addClipboardListener( const Reference< XClipboardListener >& listener )
throw( RuntimeException )
{
+ m_aCondition.wait( );
+
MutexGuard aGuard( m_aMutex );
rBHelper.aLC.addInterface( getCppuType( &listener ), listener );
}
@@ -211,6 +220,8 @@ void SAL_CALL CWinClipboard::addClipboardListener( const Reference< XClipboardLi
void SAL_CALL CWinClipboard::removeClipboardListener( const Reference< XClipboardListener >& listener )
throw( RuntimeException )
{
+ m_aCondition.wait( );
+
MutexGuard aGuard( m_aMutex );
rBHelper.aLC.removeInterface( getCppuType( &listener ), listener );
}
diff --git a/dtrans/source/win32/clipb/WinClipboard.hxx b/dtrans/source/win32/clipb/WinClipboard.hxx
index bed96ef7ff30..a34cf618c72c 100644
--- a/dtrans/source/win32/clipb/WinClipboard.hxx
+++ b/dtrans/source/win32/clipb/WinClipboard.hxx
@@ -2,9 +2,9 @@
*
* $RCSfile: WinClipboard.hxx,v $
*
- * $Revision: 1.3 $
+ * $Revision: 1.4 $
*
- * last change: $Author: tra $ $Date: 2001-03-06 13:55:02 $
+ * last change: $Author: tra $ $Date: 2001-03-07 11:23:10 $
*
* The Contents of this file are made available subject to the terms of
* either of the following licenses
@@ -108,6 +108,10 @@
#include <com/sun/star/lang/XServiceInfo.hpp>
#endif
+#ifndef _OSL_CONDITN_HXX_
+#include <osl/conditn.hxx>
+#endif
+
#include <memory>
// forward
@@ -130,8 +134,9 @@ class CWinClipbImpl;
class CWinClipboardDummy
{
protected:
- osl::Mutex m_aMutex;
- osl::Mutex m_aCbListenerMutex;
+ osl::Mutex m_aMutex;
+ osl::Mutex m_aCbListenerMutex;
+ osl::Condition m_aCondition;
};
class CWinClipboard :