[Libreoffice-commits] .: 2 commits - sd/source

Caolán McNamara caolan at kemper.freedesktop.org
Mon Apr 4 06:31:02 PDT 2011


 sd/source/ui/framework/factories/ViewShellWrapper.cxx |   20 ++++---------
 sd/source/ui/toolpanel/TaskPaneFocusManager.cxx       |   26 ++++++------------
 sd/source/ui/toolpanel/TaskPaneFocusManager.hxx       |    2 +
 sd/source/ui/unoidl/DrawController.cxx                |   19 ++++---------
 sd/source/ui/unoidl/sddetect.cxx                      |    1 
 sd/source/ui/unoidl/unomodel.cxx                      |   18 ++++--------
 sd/source/ui/unoidl/unopage.cxx                       |   18 ++++--------
 7 files changed, 37 insertions(+), 67 deletions(-)

New commits:
commit 577d4367bcf78eff01b05011549aabbe7f930c0f
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Apr 4 12:19:42 2011 +0100

    that's a completely pointless getGlobalMutex acquisition

diff --git a/sd/source/ui/unoidl/sddetect.cxx b/sd/source/ui/unoidl/sddetect.cxx
index 139cd8f..afcc9dc 100644
--- a/sd/source/ui/unoidl/sddetect.cxx
+++ b/sd/source/ui/unoidl/sddetect.cxx
@@ -520,7 +520,6 @@ UNOSEQUENCE< UNOOUSTRING > SAL_CALL SdFilterDetect::getSupportedServiceNames() t
 /* Helper for XServiceInfo */
 UNOSEQUENCE< UNOOUSTRING > SdFilterDetect::impl_getStaticSupportedServiceNames()
 {
-    UNOMUTEXGUARD aGuard( UNOMUTEX::getGlobalMutex() );
     UNOSEQUENCE< UNOOUSTRING > seqServiceNames( 1 );
     seqServiceNames.getArray() [0] = UNOOUSTRING(RTL_CONSTASCII_USTRINGPARAM( "com.sun.star.frame.ExtendedTypeDetection"  ));
     return seqServiceNames ;
commit cb4c5c2d3d2e7a4dcfdba8de6c36dbeb18692971
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Mon Apr 4 12:19:22 2011 +0100

    use rtl::Static where double-locked pattern used

diff --git a/sd/source/ui/framework/factories/ViewShellWrapper.cxx b/sd/source/ui/framework/factories/ViewShellWrapper.cxx
index f123b8b..f235090 100644
--- a/sd/source/ui/framework/factories/ViewShellWrapper.cxx
+++ b/sd/source/ui/framework/factories/ViewShellWrapper.cxx
@@ -37,9 +37,9 @@
 #include <com/sun/star/drawing/framework/XPane.hpp>
 #include <com/sun/star/lang/DisposedException.hpp>
 
-#include <rtl/uuid.h>
 #include <toolkit/helper/vclunohelper.hxx>
 #include <comphelper/sequence.hxx>
+#include <comphelper/servicehelper.hxx>
 #include <cppuhelper/typeprovider.hxx>
 #include <vcl/svapp.hxx>
 #include <osl/mutex.hxx>
@@ -177,20 +177,14 @@ sal_Bool SAL_CALL ViewShellWrapper::relocateToAnchor (
 
 //----- XUnoTunnel ------------------------------------------------------------
 
+namespace
+{
+    class theViewShellWrapperUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theViewShellWrapperUnoTunnelId> {};
+}
+
 const Sequence<sal_Int8>& ViewShellWrapper::getUnoTunnelId (void)
 {
-    static Sequence<sal_Int8>* pSequence = NULL;
-    if (pSequence == NULL)
-    {
-        const ::osl::MutexGuard aGuard( ::osl::Mutex::getGlobalMutex() );
-        if (pSequence == NULL)
-        {
-            static ::com::sun::star::uno::Sequence<sal_Int8> aSequence (16);
-            rtl_createUuid((sal_uInt8*)aSequence.getArray(), 0, sal_True);
-            pSequence = &aSequence;
-        }
-    }
-    return *pSequence;
+    return theViewShellWrapperUnoTunnelId::get().getSeq();
 }
 
 
diff --git a/sd/source/ui/toolpanel/TaskPaneFocusManager.cxx b/sd/source/ui/toolpanel/TaskPaneFocusManager.cxx
index eef81be..5442551 100644
--- a/sd/source/ui/toolpanel/TaskPaneFocusManager.cxx
+++ b/sd/source/ui/toolpanel/TaskPaneFocusManager.cxx
@@ -69,27 +69,19 @@ class FocusManager::LinkMap
 {
 };
 
+struct FocusManagerCreator
+{
+    FocusManager m_aFocusManager;
+};
 
+namespace
+{
+    class theFocusManagerInstance : public rtl::Static< FocusManagerCreator, theFocusManagerInstance> {};
+}
 
 FocusManager& FocusManager::Instance (void)
 {
-    static FocusManager* spInstance = NULL;
-
-    if (spInstance == NULL)
-    {
-        ::osl::MutexGuard aGuard (::osl::Mutex::getGlobalMutex());
-        if (spInstance == NULL)
-        {
-            static FocusManager aInstance;
-            OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
-            spInstance = &aInstance;
-        }
-    }
-    else
-    {
-        OSL_DOUBLE_CHECKED_LOCKING_MEMORY_BARRIER();
-    }
-    return *spInstance;
+    return theFocusManagerInstance::get().m_aFocusManager;
 }
 
 
diff --git a/sd/source/ui/toolpanel/TaskPaneFocusManager.hxx b/sd/source/ui/toolpanel/TaskPaneFocusManager.hxx
index a3102dc..cf26d3e 100644
--- a/sd/source/ui/toolpanel/TaskPaneFocusManager.hxx
+++ b/sd/source/ui/toolpanel/TaskPaneFocusManager.hxx
@@ -104,6 +104,8 @@ public:
     bool TransferFocus (::Window* pSource, const KeyCode& rCode);
 
 private:
+    friend struct FocusManagerCreator;
+
     class LinkMap;
     ::std::auto_ptr<LinkMap> mpLinks;
     
diff --git a/sd/source/ui/unoidl/DrawController.cxx b/sd/source/ui/unoidl/DrawController.cxx
index 523064f..26023d5 100644
--- a/sd/source/ui/unoidl/DrawController.cxx
+++ b/sd/source/ui/unoidl/DrawController.cxx
@@ -43,6 +43,7 @@
 #include <comphelper/processfactory.hxx>
 #include <comphelper/sequence.hxx>
 #include <comphelper/stl_types.hxx>
+#include <comphelper/servicehelper.hxx>
 #include <cppuhelper/exc_hlp.hxx>
 #include <cppuhelper/bootstrap.hxx>
 
@@ -612,20 +613,14 @@ Reference<XModuleController> SAL_CALL
 
 //===== XUnoTunnel ============================================================
 
+namespace
+{
+    class theDrawControllerUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theDrawControllerUnoTunnelId> {};
+}
+
 const Sequence<sal_Int8>& DrawController::getUnoTunnelId (void)
 {
-    static ::com::sun::star::uno::Sequence<sal_Int8>* pSequence = NULL;
-    if (pSequence == NULL)
-    {
-        ::osl::Guard< ::osl::Mutex > aGuard (::osl::Mutex::getGlobalMutex());
-        if (pSequence == NULL)
-        {
-            static ::com::sun::star::uno::Sequence<sal_Int8> aSequence (16);
-            rtl_createUuid((sal_uInt8*)aSequence.getArray(), 0, sal_True);
-            pSequence = &aSequence;
-        }
-    }
-    return *pSequence;
+    return theDrawControllerUnoTunnelId::get().getSeq();
 }
 
 
diff --git a/sd/source/ui/unoidl/unomodel.cxx b/sd/source/ui/unoidl/unomodel.cxx
index 78eb0d8..d9c6890 100644
--- a/sd/source/ui/unoidl/unomodel.cxx
+++ b/sd/source/ui/unoidl/unomodel.cxx
@@ -313,21 +313,15 @@ void SAL_CALL SdXImpressDocument::release() throw ( )
     }
 }
 
+namespace
+{
+    class theSdXImpressDocumentUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSdXImpressDocumentUnoTunnelId> {};
+}
+
 // XUnoTunnel
 const ::com::sun::star::uno::Sequence< sal_Int8 > & SdXImpressDocument::getUnoTunnelId() throw()
 {
-    static ::com::sun::star::uno::Sequence< sal_Int8 > * pSeq = 0;
-    if( !pSeq )
-    {
-        ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() );
-        if( !pSeq )
-        {
-            static ::com::sun::star::uno::Sequence< sal_Int8 > aSeq( 16 );
-            rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
-            pSeq = &aSeq;
-        }
-    }
-    return *pSeq;
+    return theSdXImpressDocumentUnoTunnelId::get().getSeq();
 }
 
 SdXImpressDocument* SdXImpressDocument::getImplementation( const uno::Reference< uno::XInterface >& xInt )
diff --git a/sd/source/ui/unoidl/unopage.cxx b/sd/source/ui/unoidl/unopage.cxx
index 8e333fd..1193081 100644
--- a/sd/source/ui/unoidl/unopage.cxx
+++ b/sd/source/ui/unoidl/unopage.cxx
@@ -339,20 +339,14 @@ const SvxItemPropertySet* ImplGetMasterPagePropertySet( PageKind ePageKind )
     return pRet;
 }
 
+namespace
+{
+    class theSdGenericDrawPageUnoTunnelId : public rtl::Static< UnoTunnelIdInit, theSdGenericDrawPageUnoTunnelId> {};
+}
+
 const ::com::sun::star::uno::Sequence< sal_Int8 > & SdGenericDrawPage::getUnoTunnelId() throw()
 {
-        static ::com::sun::star::uno::Sequence< sal_Int8 > * pSeq = 0;
-        if( !pSeq )
-        {
-                ::osl::Guard< ::osl::Mutex > aGuard( ::osl::Mutex::getGlobalMutex() );
-                if( !pSeq )
-                {
-                        static ::com::sun::star::uno::Sequence< sal_Int8 > aSeq( 16 );
-                        rtl_createUuid( (sal_uInt8*)aSeq.getArray(), 0, sal_True );
-                        pSeq = &aSeq;
-                }
-        }
-        return *pSeq;
+    return theSdGenericDrawPageUnoTunnelId::get().getSeq();
 }
 
 sal_Int64 SAL_CALL SdGenericDrawPage::getSomething( const ::com::sun::star::uno::Sequence< sal_Int8 >& rId ) throw(::com::sun::star::uno::RuntimeException)


More information about the Libreoffice-commits mailing list