[Libreoffice-commits] core.git: accessibility/source basctl/source cui/source desktop/source editeng/source extensions/source fpicker/source framework/source starmath/source svtools/source sw/source uui/source vcl/source

Pranav Kant pranav913 at gmail.com
Fri Mar 20 05:18:31 PDT 2015


 accessibility/source/standard/vclxaccessibleedit.cxx          |    8 +
 accessibility/source/standard/vclxaccessiblelistitem.cxx      |    3 
 accessibility/source/standard/vclxaccessiblemenuitem.cxx      |    6 -
 accessibility/source/standard/vclxaccessiblestatusbaritem.cxx |    5 -
 accessibility/source/standard/vclxaccessibletabpage.cxx       |    5 -
 accessibility/source/standard/vclxaccessibletextcomponent.cxx |    5 -
 accessibility/source/standard/vclxaccessibletoolboxitem.cxx   |    5 -
 basctl/source/basicide/baside2.cxx                            |   11 +-
 basctl/source/dlged/dlged.cxx                                 |   18 ++-
 cui/source/dialogs/colorpicker.cxx                            |    5 -
 desktop/source/app/app.cxx                                    |   33 +++---
 editeng/source/editeng/impedit.cxx                            |   42 ++++----
 extensions/source/bibliography/framectr.cxx                   |   14 +-
 fpicker/source/win32/filepicker/asyncrequests.cxx             |    4 
 framework/source/uielement/complextoolbarcontroller.cxx       |    6 -
 framework/source/uielement/generictoolbarcontroller.cxx       |    3 
 framework/source/uielement/menubarmanager.cxx                 |    3 
 starmath/source/accessibility.cxx                             |    4 
 svtools/source/misc/transfer.cxx                              |   49 +++-------
 svtools/source/uno/contextmenuhelper.cxx                      |    4 
 sw/source/uibase/uiview/viewling.cxx                          |    3 
 uui/source/iahndl.cxx                                         |    6 -
 vcl/source/app/session.cxx                                    |   13 --
 vcl/source/app/svmain.cxx                                     |   10 +-
 vcl/source/app/unohelp2.cxx                                   |    3 
 vcl/source/control/edit.cxx                                   |   24 ++--
 vcl/source/edit/textview.cxx                                  |   19 +--
 vcl/source/helper/threadex.cxx                                |    4 
 vcl/source/window/winproc.cxx                                 |    4 
 29 files changed, 137 insertions(+), 182 deletions(-)

New commits:
commit 33de587e95dddfc8e3c89b84f90b3d1bca823dae
Author: Pranav Kant <pranav913 at gmail.com>
Date:   Tue Mar 17 12:56:54 2015 +0530

    tdf#88230: cleanup solar mutex yielding
    
    Use SolarMutexReleaser, instead.
    
    Change-Id: I276459c42b688813ea168d6fc80466a07a5ecba4
    Signed-off-by: Stephan Bergmann <sbergman at redhat.com>

diff --git a/accessibility/source/standard/vclxaccessibleedit.cxx b/accessibility/source/standard/vclxaccessibleedit.cxx
index 1cce874..1b9027d 100644
--- a/accessibility/source/standard/vclxaccessibleedit.cxx
+++ b/accessibility/source/standard/vclxaccessibleedit.cxx
@@ -513,9 +513,11 @@ sal_Bool VCLXAccessibleEdit::pasteText( sal_Int32 nIndex ) throw (IndexOutOfBoun
         Reference< datatransfer::clipboard::XClipboard > xClipboard = GetWindow()->GetClipboard();
         if ( xClipboard.is() )
         {
-            const sal_uInt32 nRef = Application::ReleaseSolarMutex();
-            Reference< datatransfer::XTransferable > xDataObj = xClipboard->getContents();
-            Application::AcquireSolarMutex( nRef );
+            Reference< datatransfer::XTransferable > xDataObj;
+            {
+                SolarMutexReleaser aReleaser;
+                xDataObj = xClipboard->getContents();
+            }
             if ( xDataObj.is() )
             {
                 datatransfer::DataFlavor aFlavor;
diff --git a/accessibility/source/standard/vclxaccessiblelistitem.cxx b/accessibility/source/standard/vclxaccessiblelistitem.cxx
index 96f8a24..7e934e2 100644
--- a/accessibility/source/standard/vclxaccessiblelistitem.cxx
+++ b/accessibility/source/standard/vclxaccessiblelistitem.cxx
@@ -577,12 +577,11 @@ sal_Bool SAL_CALL VCLXAccessibleListItem::copyText( sal_Int32 nStartIndex, sal_I
             OUString sText( getTextRange( nStartIndex, nEndIndex ) );
             ::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( sText );
 
-            const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+            SolarMutexReleaser aReleaser;
             xClipboard->setContents( pDataObj, NULL );
             Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
             if( xFlushableClipboard.is() )
                 xFlushableClipboard->flushClipboard();
-            Application::AcquireSolarMutex( nRef );
 
             bRet = true;
         }
diff --git a/accessibility/source/standard/vclxaccessiblemenuitem.cxx b/accessibility/source/standard/vclxaccessiblemenuitem.cxx
index 07ba2cc..24f8ef5 100644
--- a/accessibility/source/standard/vclxaccessiblemenuitem.cxx
+++ b/accessibility/source/standard/vclxaccessiblemenuitem.cxx
@@ -404,15 +404,13 @@ sal_Bool VCLXAccessibleMenuItem::copyText( sal_Int32 nStartIndex, sal_Int32 nEnd
                 OUString sText( getTextRange( nStartIndex, nEndIndex ) );
 
                 ::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( sText );
-                const sal_uInt32 nRef = Application::ReleaseSolarMutex();
-                xClipboard->setContents( pDataObj, NULL );
 
+                SolarMutexReleaser aReleaser;
+                xClipboard->setContents( pDataObj, NULL );
                 Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
                 if( xFlushableClipboard.is() )
                     xFlushableClipboard->flushClipboard();
 
-                Application::AcquireSolarMutex( nRef );
-
                 bReturn = true;
             }
         }
diff --git a/accessibility/source/standard/vclxaccessiblestatusbaritem.cxx b/accessibility/source/standard/vclxaccessiblestatusbaritem.cxx
index 089176f..2ac6bf1 100644
--- a/accessibility/source/standard/vclxaccessiblestatusbaritem.cxx
+++ b/accessibility/source/standard/vclxaccessiblestatusbaritem.cxx
@@ -592,15 +592,14 @@ sal_Bool VCLXAccessibleStatusBarItem::copyText( sal_Int32 nStartIndex, sal_Int32
             OUString sText( getTextRange( nStartIndex, nEndIndex ) );
 
             ::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( sText );
-            const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+
+            SolarMutexReleaser aReleaser;
             xClipboard->setContents( pDataObj, NULL );
 
             Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
             if( xFlushableClipboard.is() )
                 xFlushableClipboard->flushClipboard();
 
-            Application::AcquireSolarMutex( nRef );
-
             bReturn = true;
         }
     }
diff --git a/accessibility/source/standard/vclxaccessibletabpage.cxx b/accessibility/source/standard/vclxaccessibletabpage.cxx
index 61a091a..34aac11 100644
--- a/accessibility/source/standard/vclxaccessibletabpage.cxx
+++ b/accessibility/source/standard/vclxaccessibletabpage.cxx
@@ -665,15 +665,14 @@ sal_Bool VCLXAccessibleTabPage::copyText( sal_Int32 nStartIndex, sal_Int32 nEndI
             OUString sText( getTextRange( nStartIndex, nEndIndex ) );
 
             ::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( sText );
-            const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+
+            SolarMutexReleaser aReleaser;
             xClipboard->setContents( pDataObj, NULL );
 
             Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
             if( xFlushableClipboard.is() )
                 xFlushableClipboard->flushClipboard();
 
-            Application::AcquireSolarMutex( nRef );
-
             bReturn = true;
         }
     }
diff --git a/accessibility/source/standard/vclxaccessibletextcomponent.cxx b/accessibility/source/standard/vclxaccessibletextcomponent.cxx
index 111f957..1bfa189 100644
--- a/accessibility/source/standard/vclxaccessibletextcomponent.cxx
+++ b/accessibility/source/standard/vclxaccessibletextcomponent.cxx
@@ -384,15 +384,14 @@ sal_Bool VCLXAccessibleTextComponent::copyText( sal_Int32 nStartIndex, sal_Int32
             OUString sText( getTextRange( nStartIndex, nEndIndex ) );
 
             ::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( sText );
-            const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+
+            SolarMutexReleaser aReleaser;
             xClipboard->setContents( pDataObj, NULL );
 
             Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
             if( xFlushableClipboard.is() )
                 xFlushableClipboard->flushClipboard();
 
-            Application::AcquireSolarMutex( nRef );
-
             bReturn = true;
         }
     }
diff --git a/accessibility/source/standard/vclxaccessibletoolboxitem.cxx b/accessibility/source/standard/vclxaccessibletoolboxitem.cxx
index 8d3b455..3209711 100644
--- a/accessibility/source/standard/vclxaccessibletoolboxitem.cxx
+++ b/accessibility/source/standard/vclxaccessibletoolboxitem.cxx
@@ -523,15 +523,14 @@ sal_Bool SAL_CALL VCLXAccessibleToolBoxItem::copyText( sal_Int32 nStartIndex, sa
             OUString sText( getTextRange( nStartIndex, nEndIndex ) );
 
             ::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( sText );
-            const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+
+            SolarMutexReleaser aReleaser;
             xClipboard->setContents( pDataObj, NULL );
 
             Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
             if( xFlushableClipboard.is() )
                 xFlushableClipboard->flushClipboard();
 
-            Application::AcquireSolarMutex( nRef );
-
             bReturn = true;
         }
     }
diff --git a/basctl/source/basicide/baside2.cxx b/basctl/source/basicide/baside2.cxx
index eb9ef96..81d0f34 100644
--- a/basctl/source/basicide/baside2.cxx
+++ b/basctl/source/basicide/baside2.cxx
@@ -1405,10 +1405,13 @@ bool ModulWindow::IsPasteAllowed()
     Reference< datatransfer::clipboard::XClipboard > xClipboard = GetClipboard();
     if ( xClipboard.is() )
     {
-        // get clipboard content
-        const sal_uInt32 nRef = Application::ReleaseSolarMutex();
-        Reference< datatransfer::XTransferable > xTransf = xClipboard->getContents();
-        Application::AcquireSolarMutex( nRef );
+
+        Reference< datatransfer::XTransferable > xTransf;
+        {
+            SolarMutexReleaser aReleaser;
+            // get clipboard content
+            xTransf = xClipboard->getContents();
+        }
         if ( xTransf.is() )
         {
             datatransfer::DataFlavor aFlavor;
diff --git a/basctl/source/dlged/dlged.cxx b/basctl/source/dlged/dlged.cxx
index 2847f58..62109c3 100644
--- a/basctl/source/dlged/dlged.cxx
+++ b/basctl/source/dlged/dlged.cxx
@@ -811,9 +811,8 @@ void DlgEditor::Copy()
             aSeqData[0] = aDialogModelBytesAny;
             pTrans = new DlgEdTransferableImpl( m_ClipboardDataFlavors , aSeqData );
         }
-        const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+        SolarMutexReleaser aReleaser;
         xClipboard->setContents( pTrans , pTrans );
-        Application::AcquireSolarMutex( nRef );
     }
 }
 
@@ -830,10 +829,13 @@ void DlgEditor::Paste()
     Reference< datatransfer::clipboard::XClipboard > xClipboard = GetWindow().GetClipboard();
     if ( xClipboard.is() )
     {
-        // get clipboard content
-        const sal_uInt32 nRef = Application::ReleaseSolarMutex();
-        Reference< datatransfer::XTransferable > xTransf = xClipboard->getContents();
-        Application::AcquireSolarMutex( nRef );
+        Reference< datatransfer::XTransferable > xTransf;
+
+        {
+            SolarMutexReleaser aReleaser;
+            // get clipboard content
+            xTransf = xClipboard->getContents();
+        }
         if ( xTransf.is() )
         {
             // Is target dialog (library) localized?
@@ -1061,9 +1063,9 @@ bool DlgEditor::IsPasteAllowed()
     if ( xClipboard.is() )
     {
         // get clipboard content
-        const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+        SolarMutexReleaser aReleaser;
         Reference< datatransfer::XTransferable > xTransf = xClipboard->getContents();
-        Application::AcquireSolarMutex( nRef );
+
         return xTransf.is() && xTransf->isDataFlavorSupported( m_ClipboardDataFlavors[0] );
     }
     return false;
diff --git a/cui/source/dialogs/colorpicker.cxx b/cui/source/dialogs/colorpicker.cxx
index 13fe8351..798597b 100644
--- a/cui/source/dialogs/colorpicker.cxx
+++ b/cui/source/dialogs/colorpicker.cxx
@@ -204,18 +204,15 @@ void HexColorControl::Paste()
     {
         ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::XTransferable > xDataObj;
 
-        const sal_uInt32 nRef = Application::ReleaseSolarMutex();
-
         try
         {
+            SolarMutexReleaser aReleaser;
             xDataObj = aClipboard->getContents();
         }
         catch( const ::com::sun::star::uno::Exception& )
         {
         }
 
-        Application::AcquireSolarMutex( nRef );
-
         if ( xDataObj.is() )
         {
             ::com::sun::star::datatransfer::DataFlavor aFlavor;
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index 62402e0..cd9809d 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -1588,22 +1588,22 @@ int Desktop::Main()
         }
 
         // Release solar mutex just before we wait for our client to connect
-        int nAcquireCount = Application::ReleaseSolarMutex();
+        {
+            SolarMutexReleaser aReleaser;
 
-        // Post user event to startup first application component window
-        // We have to send this OpenClients message short before execute() to
-        // minimize the risk that this message overtakes type detection construction!!
-        Application::PostUserEvent( LINK( this, Desktop, OpenClients_Impl ) );
+            // Post user event to startup first application component window
+            // We have to send this OpenClients message short before execute() to
+            // minimize the risk that this message overtakes type detection construction!!
+            Application::PostUserEvent( LINK( this, Desktop, OpenClients_Impl ) );
 
-        // Post event to enable acceptors
-        Application::PostUserEvent( LINK( this, Desktop, EnableAcceptors_Impl) );
+            // Post event to enable acceptors
+            Application::PostUserEvent( LINK( this, Desktop, EnableAcceptors_Impl) );
 
-        // The configuration error handler currently is only for startup
-        aConfigErrHandler.deactivate();
+            // The configuration error handler currently is only for startup
+            aConfigErrHandler.deactivate();
 
-       // Acquire solar mutex just before we enter our message loop
-        if ( nAcquireCount )
-            Application::AcquireSolarMutex( nAcquireCount );
+            // Acquire solar mutex just before we enter our message loop
+        }
 
         // call Application::Execute to process messages in vcl message loop
         SAL_INFO( "desktop.app", "PERFORMANCE - enter Application::Execute()" );
@@ -1711,12 +1711,13 @@ int Desktop::doShutdown()
     FlushConfiguration();
     // The acceptors in the AcceptorMap must be released (in DeregisterServices)
     // with the solar mutex unlocked, to avoid deadlock:
-    sal_uLong nAcquireCount = Application::ReleaseSolarMutex();
-    DeregisterServices();
+    {
+        SolarMutexReleaser aReleaser;
+        DeregisterServices();
 #if HAVE_FEATURE_SCRIPTING
-    StarBASIC::DetachAllDocBasicItems();
+        StarBASIC::DetachAllDocBasicItems();
 #endif
-    Application::AcquireSolarMutex(nAcquireCount);
+    }
     // be sure that path/language options gets destroyed before
     // UCB is deinitialized
     SAL_INFO( "desktop.app", "-> dispose path/language options" );
diff --git a/editeng/source/editeng/impedit.cxx b/editeng/source/editeng/impedit.cxx
index f0af594..3553707 100644
--- a/editeng/source/editeng/impedit.cxx
+++ b/editeng/source/editeng/impedit.cxx
@@ -1313,22 +1313,23 @@ void ImpEditView::CutCopy( ::com::sun::star::uno::Reference< ::com::sun::star::d
     {
         uno::Reference<datatransfer::XTransferable> xData = pEditEngine->CreateTransferable( GetEditSelection() );
 
-        const sal_uInt32 nRef = Application::ReleaseSolarMutex();
-
-        try
         {
-            rxClipboard->setContents( xData, NULL );
+            SolarMutexReleaser aReleaser;
 
-            // #87756# FlushClipboard, but it would be better to become a TerminateListener to the Desktop and flush on demand...
-            uno::Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( rxClipboard, uno::UNO_QUERY );
-            if( xFlushableClipboard.is() )
-                xFlushableClipboard->flushClipboard();
-        }
-        catch( const ::com::sun::star::uno::Exception& )
-        {
-        }
+            try
+                {
+                    rxClipboard->setContents( xData, NULL );
+
+                    // #87756# FlushClipboard, but it would be better to become a TerminateListener to the Desktop and flush on demand...
+                    uno::Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( rxClipboard, uno::UNO_QUERY );
+                    if( xFlushableClipboard.is() )
+                        xFlushableClipboard->flushClipboard();
+                }
+            catch( const ::com::sun::star::uno::Exception& )
+                {
+                }
 
-        Application::AcquireSolarMutex( nRef );
+        }
 
         if ( bCut )
         {
@@ -1346,17 +1347,14 @@ void ImpEditView::Paste( ::com::sun::star::uno::Reference< ::com::sun::star::dat
     {
         uno::Reference< datatransfer::XTransferable > xDataObj;
 
-        const sal_uInt32 nRef = Application::ReleaseSolarMutex();
-
         try
-        {
-            xDataObj = rxClipboard->getContents();
-        }
+            {
+                SolarMutexReleaser aReleaser;
+                xDataObj = rxClipboard->getContents();
+            }
         catch( const ::com::sun::star::uno::Exception& )
-        {
-        }
-
-        Application::AcquireSolarMutex( nRef );
+            {
+            }
 
         if ( xDataObj.is() && EditEngine::HasValidData( xDataObj ) )
         {
diff --git a/extensions/source/bibliography/framectr.cxx b/extensions/source/bibliography/framectr.cxx
index 81617fa..77ea325 100644
--- a/extensions/source/bibliography/framectr.cxx
+++ b/extensions/source/bibliography/framectr.cxx
@@ -730,15 +730,15 @@ void BibFrameController_Impl::addStatusListener(
             if(xClip.is())
             {
                 uno::Reference< datatransfer::XTransferable > xDataObj;
-                const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+
                 try
-                {
-                    xDataObj = xClip->getContents();
-                }
+                    {
+                        SolarMutexReleaser aReleaser;
+                        xDataObj = xClip->getContents();
+                    }
                 catch( const uno::Exception& )
-                {
-                }
-                Application::AcquireSolarMutex( nRef );
+                    {
+                    }
 
                 if ( xDataObj.is() )
                 {
diff --git a/fpicker/source/win32/filepicker/asyncrequests.cxx b/fpicker/source/win32/filepicker/asyncrequests.cxx
index e8ca9bc..87e53fa 100644
--- a/fpicker/source/win32/filepicker/asyncrequests.cxx
+++ b/fpicker/source/win32/filepicker/asyncrequests.cxx
@@ -28,7 +28,7 @@ namespace vista{
 static void lcl_sleep( ::osl::Condition& aCondition,
                        ::sal_Int32       nMilliSeconds )
 {
-    sal_uLong nAcquireCount = Application::ReleaseSolarMutex();
+    SolarMutexReleaser aReleaser;
 
     if (nMilliSeconds < 1)
         aCondition.wait(0);
@@ -39,8 +39,6 @@ static void lcl_sleep( ::osl::Condition& aCondition,
         aTime.Nanosec = (nMilliSeconds % 1000) * 1000000;
         aCondition.wait(&aTime);
     }
-
-    Application::AcquireSolarMutex( nAcquireCount );
 }
 
 void Request::wait( ::sal_Int32 nMilliSeconds )
diff --git a/framework/source/uielement/complextoolbarcontroller.cxx b/framework/source/uielement/complextoolbarcontroller.cxx
index 4902688..871c7b2 100644
--- a/framework/source/uielement/complextoolbarcontroller.cxx
+++ b/framework/source/uielement/complextoolbarcontroller.cxx
@@ -198,7 +198,7 @@ throw ( RuntimeException, std::exception )
 
 IMPL_STATIC_LINK_NOINSTANCE( ComplexToolbarController, ExecuteHdl_Impl, ExecuteInfo*, pExecuteInfo )
 {
-   const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+   SolarMutexReleaser aReleaser;
    try
    {
        // Asynchronous execution as this can lead to our own destruction!
@@ -210,14 +210,13 @@ IMPL_STATIC_LINK_NOINSTANCE( ComplexToolbarController, ExecuteHdl_Impl, ExecuteI
    {
    }
 
-   Application::AcquireSolarMutex( nRef );
    delete pExecuteInfo;
    return 0;
 }
 
 IMPL_STATIC_LINK_NOINSTANCE( ComplexToolbarController, Notify_Impl, NotifyInfo*, pNotifyInfo )
 {
-   const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+   SolarMutexReleaser aReleaser;
    try
    {
        // Asynchronous execution: As this can lead to our own destruction!
@@ -233,7 +232,6 @@ IMPL_STATIC_LINK_NOINSTANCE( ComplexToolbarController, Notify_Impl, NotifyInfo*,
    {
    }
 
-   Application::AcquireSolarMutex( nRef );
    delete pNotifyInfo;
    return 0;
 }
diff --git a/framework/source/uielement/generictoolbarcontroller.cxx b/framework/source/uielement/generictoolbarcontroller.cxx
index f72ae03..f59982a 100644
--- a/framework/source/uielement/generictoolbarcontroller.cxx
+++ b/framework/source/uielement/generictoolbarcontroller.cxx
@@ -271,7 +271,7 @@ throw ( RuntimeException, std::exception )
 
 IMPL_STATIC_LINK_NOINSTANCE( GenericToolbarController, ExecuteHdl_Impl, ExecuteInfo*, pExecuteInfo )
 {
-   const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+   SolarMutexReleaser aReleaser;
    try
    {
         // Asynchronous execution as this can lead to our own destruction!
@@ -283,7 +283,6 @@ IMPL_STATIC_LINK_NOINSTANCE( GenericToolbarController, ExecuteHdl_Impl, ExecuteI
    {
    }
 
-   Application::AcquireSolarMutex( nRef );
    delete pExecuteInfo;
    return 0;
 }
diff --git a/framework/source/uielement/menubarmanager.cxx b/framework/source/uielement/menubarmanager.cxx
index 8cfe80c..af103c3 100644
--- a/framework/source/uielement/menubarmanager.cxx
+++ b/framework/source/uielement/menubarmanager.cxx
@@ -1019,9 +1019,8 @@ IMPL_LINK( MenuBarManager, Select, Menu *, pMenu )
 
     if ( xDispatch.is() )
     {
-        const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+        SolarMutexReleaser aReleaser;
         xDispatch->dispatch( aTargetURL, aArgs );
-        Application::AcquireSolarMutex( nRef );
     }
 
     return 1;
diff --git a/starmath/source/accessibility.cxx b/starmath/source/accessibility.cxx
index 6973dfd..cd6c587 100644
--- a/starmath/source/accessibility.cxx
+++ b/starmath/source/accessibility.cxx
@@ -756,15 +756,13 @@ sal_Bool SAL_CALL SmGraphicAccessible::copyText(
             OUString sText( getTextRange(nStartIndex, nEndIndex) );
 
             ::vcl::unohelper::TextDataObject* pDataObj = new ::vcl::unohelper::TextDataObject( sText );
-            const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+            SolarMutexReleaser aReleaser;
             xClipboard->setContents( pDataObj, NULL );
 
             Reference< datatransfer::clipboard::XFlushableClipboard > xFlushableClipboard( xClipboard, uno::UNO_QUERY );
             if( xFlushableClipboard.is() )
                 xFlushableClipboard->flushClipboard();
 
-            Application::AcquireSolarMutex( nRef );
-
             bReturn = true;
         }
     }
diff --git a/svtools/source/misc/transfer.cxx b/svtools/source/misc/transfer.cxx
index 4e0ef5c..9de9349 100644
--- a/svtools/source/misc/transfer.cxx
+++ b/svtools/source/misc/transfer.cxx
@@ -571,7 +571,7 @@ void TransferableHelper::ImplFlush()
     if( mxClipboard.is() )
     {
         Reference< XFlushableClipboard >    xFlushableClipboard( mxClipboard, UNO_QUERY );
-        const sal_uInt32                    nRef = Application::ReleaseSolarMutex();
+        SolarMutexReleaser aReleaser;
 
         try
         {
@@ -582,8 +582,6 @@ void TransferableHelper::ImplFlush()
         {
             OSL_FAIL( "Could not flush clipboard" );
         }
-
-        Application::AcquireSolarMutex( nRef );
     }
 }
 
@@ -1019,7 +1017,7 @@ void TransferableHelper::CopyToClipboard( vcl::Window *pWindow ) const
 
     if( mxClipboard.is() && !mxTerminateListener.is() )
     {
-        const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+        SolarMutexReleaser aReleaser;
 
         try
         {
@@ -1032,8 +1030,6 @@ void TransferableHelper::CopyToClipboard( vcl::Window *pWindow ) const
         catch( const ::com::sun::star::uno::Exception& )
         {
         }
-
-        Application::AcquireSolarMutex( nRef );
     }
 }
 
@@ -1049,7 +1045,7 @@ void TransferableHelper::CopyToSelection( vcl::Window *pWindow ) const
 
     if( xSelection.is() && !mxTerminateListener.is() )
     {
-        const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+        SolarMutexReleaser aReleaser;
 
         try
         {
@@ -1062,8 +1058,6 @@ void TransferableHelper::CopyToSelection( vcl::Window *pWindow ) const
         catch( const ::com::sun::star::uno::Exception& )
         {
         }
-
-        Application::AcquireSolarMutex( nRef );
     }
 }
 
@@ -1092,7 +1086,7 @@ void TransferableHelper::StartDrag( vcl::Window* pWindow, sal_Int8 nDnDSourceAct
         // we can receive drag events from the system only in the main
         // thread
 #if !defined(MACOSX)
-        const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+        SolarMutexReleaser aReleaser;
 #endif
 
         try
@@ -1108,11 +1102,6 @@ void TransferableHelper::StartDrag( vcl::Window* pWindow, sal_Int8 nDnDSourceAct
         catch( const ::com::sun::star::uno::Exception& )
         {
         }
-
-        // See above for the reason of this define
-#if !defined(MACOSX)
-        Application::AcquireSolarMutex( nRef );
-#endif
     }
 }
 
@@ -2283,24 +2272,22 @@ TransferableDataHelper TransferableDataHelper::CreateFromSelection( vcl::Window*
 
     if( xSelection.is() )
        {
-        const sal_uInt32 nRef = Application::ReleaseSolarMutex();
-
-          try
-        {
-            Reference< XTransferable > xTransferable( xSelection->getContents() );
+           SolarMutexReleaser aReleaser;
 
-            if( xTransferable.is() )
+           try
                {
-                aRet = TransferableDataHelper( xTransferable );
-                   aRet.mxClipboard = xSelection;
-            }
-           }
-        catch( const ::com::sun::star::uno::Exception& )
-        {
-           }
-
-        Application::AcquireSolarMutex( nRef );
-    }
+                   Reference< XTransferable > xTransferable( xSelection->getContents() );
+
+                   if( xTransferable.is() )
+                       {
+                           aRet = TransferableDataHelper( xTransferable );
+                           aRet.mxClipboard = xSelection;
+                       }
+               }
+           catch( const ::com::sun::star::uno::Exception& )
+               {
+               }
+       }
 
     return aRet;
 }
diff --git a/svtools/source/uno/contextmenuhelper.cxx b/svtools/source/uno/contextmenuhelper.cxx
index 3d7058c..943c2d8 100644
--- a/svtools/source/uno/contextmenuhelper.cxx
+++ b/svtools/source/uno/contextmenuhelper.cxx
@@ -612,7 +612,7 @@ ContextMenuHelper::completeMenuProperties(
 IMPL_STATIC_LINK_NOINSTANCE( ContextMenuHelper, ExecuteHdl_Impl, ExecuteInfo*, pExecuteInfo )
 {
     // Release solar mutex to prevent deadlocks with clipboard thread
-    const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+    SolarMutexReleaser aReleaser;
     try
     {
         // Asynchronous execution as this can lead to our own destruction while we are
@@ -623,8 +623,6 @@ IMPL_STATIC_LINK_NOINSTANCE( ContextMenuHelper, ExecuteHdl_Impl, ExecuteInfo*, p
     {
     }
 
-    // Acquire solar mutex again
-    Application::AcquireSolarMutex( nRef );
     delete pExecuteInfo;
     return 0;
 }
diff --git a/sw/source/uibase/uiview/viewling.cxx b/sw/source/uibase/uiview/viewling.cxx
index 13f5478..cf80a28 100644
--- a/sw/source/uibase/uiview/viewling.cxx
+++ b/sw/source/uibase/uiview/viewling.cxx
@@ -608,7 +608,7 @@ public:
 
 IMPL_STATIC_LINK_NOINSTANCE( AsyncExecute, ExecuteHdl_Impl, ExecuteInfo*, pExecuteInfo )
 {
-    const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+    SolarMutexReleaser aReleaser;
     try
     {
         // Asynchronous execution as this can lead to our own destruction!
@@ -620,7 +620,6 @@ IMPL_STATIC_LINK_NOINSTANCE( AsyncExecute, ExecuteHdl_Impl, ExecuteInfo*, pExecu
     {
     }
 
-    Application::AcquireSolarMutex( nRef );
     delete pExecuteInfo;
     return 0;
 }
diff --git a/uui/source/iahndl.cxx b/uui/source/iahndl.cxx
index afbc211..15a3492 100644
--- a/uui/source/iahndl.cxx
+++ b/uui/source/iahndl.cxx
@@ -178,9 +178,8 @@ UUIInteractionHelper::handleRequest(
         HandleData aHD(rRequest);
         Link aLink(&aHD,handlerequest);
         Application::PostUserEvent(aLink,this);
-        sal_uLong locks = Application::ReleaseSolarMutex();
+        SolarMutexReleaser aReleaser;
         aHD.wait();
-        Application::AcquireSolarMutex(locks);
         return aHD.bHandled;
     }
     else
@@ -235,9 +234,8 @@ UUIInteractionHelper::getStringFromRequest(
         HandleData aHD(rRequest);
         Link aLink(&aHD,getstringfromrequest);
         Application::PostUserEvent(aLink,this);
-        sal_uLong locks = Application::ReleaseSolarMutex();
+        SolarMutexReleaser aReleaser;
         aHD.wait();
-        Application::AcquireSolarMutex(locks);
         return aHD.m_aResult;
     }
     else
diff --git a/vcl/source/app/session.cxx b/vcl/source/app/session.cxx
index 294a581..5db137f 100644
--- a/vcl/source/app/session.cxx
+++ b/vcl/source/app/session.cxx
@@ -134,10 +134,9 @@ void VCLSession::callSaveRequested( bool bShutdown, bool bCancelable )
         }
     }
 
-    sal_uLong nAcquireCount = Application::ReleaseSolarMutex();
+    SolarMutexReleaser aReleaser;
     for( std::list< Listener >::const_iterator it = aListeners.begin(); it != aListeners.end(); ++it )
         it->m_xListener->doSave( bShutdown, bCancelable );
-    Application::AcquireSolarMutex( nAcquireCount );
 }
 
 void VCLSession::callInteractionGranted( bool bInteractionGranted )
@@ -162,11 +161,9 @@ void VCLSession::callInteractionGranted( bool bInteractionGranted )
         }
     }
 
-    sal_uLong nAcquireCount = Application::ReleaseSolarMutex();
+    SolarMutexReleaser aReleaser;
     for( std::list< Listener >::const_iterator it = aListeners.begin(); it != aListeners.end(); ++it )
         it->m_xListener->approveInteraction( bInteractionGranted );
-
-    Application::AcquireSolarMutex( nAcquireCount );
 }
 
 void VCLSession::callShutdownCancelled()
@@ -180,10 +177,9 @@ void VCLSession::callShutdownCancelled()
         m_bInteractionRequested = m_bInteractionDone = m_bInteractionGranted = false;
     }
 
-    sal_uLong nAcquireCount = Application::ReleaseSolarMutex();
+    SolarMutexReleaser aReleaser;
     for( std::list< Listener >::const_iterator it = aListeners.begin(); it != aListeners.end(); ++it )
         it->m_xListener->shutdownCanceled();
-    Application::AcquireSolarMutex( nAcquireCount );
 }
 
 void VCLSession::callQuit()
@@ -197,14 +193,13 @@ void VCLSession::callQuit()
         m_bInteractionRequested = m_bInteractionDone = m_bInteractionGranted = false;
     }
 
-    sal_uLong nAcquireCount = Application::ReleaseSolarMutex();
+    SolarMutexReleaser aReleaser;
     for( std::list< Listener >::const_iterator it = aListeners.begin(); it != aListeners.end(); ++it )
     {
         css::uno::Reference< XSessionManagerListener2 > xListener2( it->m_xListener, UNO_QUERY );
         if( xListener2.is() )
             xListener2->doQuit();
     }
-    Application::AcquireSolarMutex( nAcquireCount );
 }
 
 void VCLSession::SalSessionEventProc( void* pData, SalSessionEvent* pEvent )
diff --git a/vcl/source/app/svmain.cxx b/vcl/source/app/svmain.cxx
index 9d59eac6..1f597e5 100644
--- a/vcl/source/app/svmain.cxx
+++ b/vcl/source/app/svmain.cxx
@@ -176,9 +176,10 @@ int ImplSVMain()
     // here ..
     if( pSVData->mxAccessBridge.is() )
     {
-      sal_uLong nCount = Application::ReleaseSolarMutex();
-      pSVData->mxAccessBridge->dispose();
-      Application::AcquireSolarMutex(nCount);
+        {
+            SolarMutexReleaser aReleaser;
+            pSVData->mxAccessBridge->dispose();
+        }
       pSVData->mxAccessBridge.clear();
     }
 
@@ -472,7 +473,7 @@ void DeInitVCL()
 
     if( pSVData->mpApp || pSVData->maDeInitHook.IsSet() )
     {
-        sal_uLong nCount = Application::ReleaseSolarMutex();
+        SolarMutexReleaser aReleaser;
         // call deinit to deinitialize application class
         // soffice/sfx implementation disposes the global service manager
         // Warning: After this call you can't call uno services
@@ -484,7 +485,6 @@ void DeInitVCL()
         {
             pSVData->maDeInitHook.Call(0);
         }
-        Application::AcquireSolarMutex(nCount);
     }
 
     if ( pSVData->maAppData.mpSettings )
diff --git a/vcl/source/app/unohelp2.cxx b/vcl/source/app/unohelp2.cxx
index 2f2e3d6..280f04e 100644
--- a/vcl/source/app/unohelp2.cxx
+++ b/vcl/source/app/unohelp2.cxx
@@ -47,7 +47,7 @@ namespace vcl { namespace unohelper {
 
         TextDataObject* pDataObj = new TextDataObject( rContent );
 
-        const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+        SolarMutexReleaser aReleaser;
         try
         {
             rxClipboard->setContents( pDataObj, NULL );
@@ -59,7 +59,6 @@ namespace vcl { namespace unohelper {
         catch( const uno::Exception& )
         {
         }
-        Application::AcquireSolarMutex( nRef );
     }
 
     // ::com::sun::star::uno::XInterface
diff --git a/vcl/source/control/edit.cxx b/vcl/source/control/edit.cxx
index fb6dde7..f704e66 100644
--- a/vcl/source/control/edit.cxx
+++ b/vcl/source/control/edit.cxx
@@ -1285,17 +1285,14 @@ void Edit::ImplPaste( uno::Reference< datatransfer::clipboard::XClipboard >& rxC
     {
         uno::Reference< datatransfer::XTransferable > xDataObj;
 
-        const sal_uInt32 nRef = Application::ReleaseSolarMutex();
-
         try
-        {
-            xDataObj = rxClipboard->getContents();
-        }
+            {
+                SolarMutexReleaser aReleaser;
+                xDataObj = rxClipboard->getContents();
+            }
         catch( const ::com::sun::star::uno::Exception& )
-        {
-        }
-
-        Application::AcquireSolarMutex( nRef );
+            {
+            }
 
         if ( xDataObj.is() )
         {
@@ -1983,11 +1980,14 @@ void Edit::Command( const CommandEvent& rCEvt )
             // only paste if text available in clipboard
             bool bData = false;
             uno::Reference< datatransfer::clipboard::XClipboard > xClipboard = GetClipboard();
+
             if ( xClipboard.is() )
             {
-                const sal_uInt32 nRef = Application::ReleaseSolarMutex();
-                uno::Reference< datatransfer::XTransferable > xDataObj = xClipboard->getContents();
-                Application::AcquireSolarMutex( nRef );
+                uno::Reference< datatransfer::XTransferable > xDataObj;
+                {
+                    SolarMutexReleaser aReleaser;
+                    xDataObj = xClipboard->getContents();
+                }
                 if ( xDataObj.is() )
                 {
                     datatransfer::DataFlavor aFlavor;
diff --git a/vcl/source/edit/textview.cxx b/vcl/source/edit/textview.cxx
index 030365f..cafbbf5 100644
--- a/vcl/source/edit/textview.cxx
+++ b/vcl/source/edit/textview.cxx
@@ -1132,7 +1132,7 @@ void TextView::Copy( uno::Reference< datatransfer::clipboard::XClipboard >& rxCl
         if ( mpImpl->mpTextEngine->HasAttrib( TEXTATTR_HYPERLINK ) )  // then also as HTML
             mpImpl->mpTextEngine->Write( pDataObj->GetHTMLStream(), &mpImpl->maSelection, true );
 
-        const sal_uInt32 nRef = Application::ReleaseSolarMutex();
+        SolarMutexReleaser aReleaser;
 
         try
         {
@@ -1145,8 +1145,6 @@ void TextView::Copy( uno::Reference< datatransfer::clipboard::XClipboard >& rxCl
         catch( const ::com::sun::star::uno::Exception& )
         {
         }
-
-        Application::AcquireSolarMutex( nRef );
     }
 }
 
@@ -1162,17 +1160,14 @@ void TextView::Paste( uno::Reference< datatransfer::clipboard::XClipboard >& rxC
     {
         uno::Reference< datatransfer::XTransferable > xDataObj;
 
-        const sal_uInt32 nRef = Application::ReleaseSolarMutex();
-
         try
-        {
-            xDataObj = rxClipboard->getContents();
-        }
+            {
+                SolarMutexReleaser aReleaser;
+                xDataObj = rxClipboard->getContents();
+            }
         catch( const ::com::sun::star::uno::Exception& )
-        {
-        }
-
-        Application::AcquireSolarMutex( nRef );
+            {
+            }
 
         if ( xDataObj.is() )
         {
diff --git a/vcl/source/helper/threadex.cxx b/vcl/source/helper/threadex.cxx
index 37d8ef8..a62bcfc 100644
--- a/vcl/source/helper/threadex.cxx
+++ b/vcl/source/helper/threadex.cxx
@@ -59,7 +59,7 @@ long SolarThreadExecutor::impl_execute( const TimeValue* _pTimeout )
     {
         osl_resetCondition( m_aStart );
         osl_resetCondition( m_aFinish );
-        sal_uLong nSolarMutexCount = Application::ReleaseSolarMutex();
+        SolarMutexReleaser aReleaser;
         ImplSVEvent * nEvent = Application::PostUserEvent( LINK( this, SolarThreadExecutor, worker ) );
         if ( osl_cond_result_timeout == osl_waitCondition( m_aStart, _pTimeout ) )
         {
@@ -68,8 +68,6 @@ long SolarThreadExecutor::impl_execute( const TimeValue* _pTimeout )
         }
         else
             osl_waitCondition( m_aFinish, NULL );
-        if( nSolarMutexCount )
-            Application::AcquireSolarMutex( nSolarMutexCount );
     }
     return m_nReturn;
 }
diff --git a/vcl/source/window/winproc.cxx b/vcl/source/window/winproc.cxx
index c9db004..537bac3f 100644
--- a/vcl/source/window/winproc.cxx
+++ b/vcl/source/window/winproc.cxx
@@ -510,7 +510,7 @@ bool ImplHandleMouseEvent( vcl::Window* pWindow, MouseNotifyEvent nSVEvent, bool
                                     nClicks,
                                     false );
 
-                                sal_uLong nCount = Application::ReleaseSolarMutex();
+                                SolarMutexReleaser aReleaser;
 
                                 // FIXME: where do I get Action from ?
                                 ::com::sun::star::uno::Reference< ::com::sun::star::datatransfer::dnd::XDragSource > xDragSource = pMouseDownWin->GetDragSource();
@@ -520,8 +520,6 @@ bool ImplHandleMouseEvent( vcl::Window* pWindow, MouseNotifyEvent nSVEvent, bool
                                     static_cast < DNDListenerContainer * > ( xDragGestureRecognizer.get() )->fireDragGestureEvent( 0,
                                         relLoc.X(), relLoc.Y(), xDragSource, ::com::sun::star::uno::makeAny( aMouseEvent ) );
                                 }
-
-                                Application::AcquireSolarMutex( nCount );
                             }
                         }
                     }


More information about the Libreoffice-commits mailing list