[Libreoffice-commits] .: 2 commits - desktop/unx editeng/inc editeng/source

Caolán McNamara caolan at kemper.freedesktop.org
Wed Mar 23 04:28:01 PDT 2011


 desktop/unx/source/start.c      |    3 -
 editeng/inc/editeng/unotext.hxx |    9 ---
 editeng/source/uno/unotext.cxx  |  106 +++++++++++++++++++++++-----------------
 editeng/source/uno/unotext2.cxx |   98 ++++++++++++++++++++++--------------
 4 files changed, 124 insertions(+), 92 deletions(-)

New commits:
commit c7fa546f50dfb103121eefe1b7483975282df451
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Mar 23 11:27:35 2011 +0000

    valgrind: don't close invalid fd

diff --git a/desktop/unx/source/start.c b/desktop/unx/source/start.c
index b59eb7d..2b9b3e3 100755
--- a/desktop/unx/source/start.c
+++ b/desktop/unx/source/start.c
@@ -877,12 +877,13 @@ SAL_IMPLEMENT_MAIN_WITH_ARGS( argc, argv )
         osl_getProcessWorkingDir( &pCwdPath );
 
         bSentArgs = send_args( fd, pCwdPath );
+
+        close( fd );
     }
 #if OSL_DEBUG_LEVEL > 0
     else
         ustr_debug( "Failed to connect to pipe", pPipePath );
 #endif
-    close( fd );
 
     if ( !bSentArgs )
     {
commit 4cea8c42b8fc300bfea02711c2336cb5fd1a69ee
Author: Caolán McNamara <caolanm at redhat.com>
Date:   Wed Mar 23 09:33:59 2011 +0000

    global uno::Sequences are very problematic at shutdown time
    
    because the underlying uno infrastructure has been shutdown already,
    we need to ensure their lifecycle more carefully.

diff --git a/editeng/inc/editeng/unotext.hxx b/editeng/inc/editeng/unotext.hxx
index 72a9d5f..3489944 100755
--- a/editeng/inc/editeng/unotext.hxx
+++ b/editeng/inc/editeng/unotext.hxx
@@ -373,9 +373,6 @@ private:
     ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > 	xParentText;
     sal_Bool mbPortion;
 
-protected:
-    static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > maTypeSequence;
-
 public:
     SvxUnoTextRange( const SvxUnoTextBase& rParent, sal_Bool bPortion = sal_False ) throw();
     virtual ~SvxUnoTextRange() throw();
@@ -406,7 +403,6 @@ class EDITENG_DLLPUBLIC SvxUnoTextBase  : public SvxUnoTextRangeBase,
 {
 protected:
     ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > 	xParentText;
-    static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > maTypeSequence;
 
 public:
     SvxUnoTextBase( ) throw();
@@ -541,8 +537,6 @@ private:
     bool mbDisposing;
 
 protected:
-    static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > maTypeSequence;
-
     using SvxUnoTextRangeBase::setPropertyValue;
     using SvxUnoTextRangeBase::getPropertyValue;
 
@@ -630,9 +624,6 @@ class EDITENG_DLLPUBLIC SvxUnoTextCursor : public SvxUnoTextRangeBase,
 private:
     ::com::sun::star::uno::Reference< ::com::sun::star::text::XText > mxParentText;
 
-protected:
-    static ::com::sun::star::uno::Sequence< ::com::sun::star::uno::Type > maTypeSequence;
-
 public:
     SvxUnoTextCursor( const SvxUnoTextBase& rText ) throw();
     SvxUnoTextCursor( const SvxUnoTextCursor& rCursor ) throw();
diff --git a/editeng/source/uno/unotext.cxx b/editeng/source/uno/unotext.cxx
index af248fc..0291681 100755
--- a/editeng/source/uno/unotext.cxx
+++ b/editeng/source/uno/unotext.cxx
@@ -40,6 +40,7 @@
 #include <svl/eitem.hxx>
 #include <rtl/uuid.h>
 #include <rtl/memory.h>
+#include <rtl/instance.hxx>
 
 #include <editeng/fontitem.hxx>
 #include <editeng/tstpitem.hxx>
@@ -1523,8 +1524,6 @@ sal_Int16 SAL_CALL SvxUnoTextRangeBase::compareRegionEnds( const uno::Reference<
 // class SvxUnoTextRange
 // ====================================================================
 
-uno::Sequence< uno::Type > SvxUnoTextRange::maTypeSequence;
-
 uno::Reference< uno::XInterface > SvxUnoTextRange_NewInstance()
 {
     SvxUnoText aText;
@@ -1586,25 +1585,37 @@ void SAL_CALL SvxUnoTextRange::release()
 
 // XTypeProvider
 
+namespace
+{
+    struct theSvxUnoTextRangeTypes :
+        public rtl::StaticWithInit<uno::Sequence<uno::Type>, theSvxUnoTextRangeTypes>
+    {
+        uno::Sequence<uno::Type> operator () ()
+        {
+            uno::Sequence< uno::Type > aTypeSequence;
+
+            aTypeSequence.realloc( 9 ); // !DANGER! keep this updated
+            uno::Type* pTypes = aTypeSequence.getArray();
+
+            *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRange >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertySet >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertySet >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertyStates >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertyState >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< lang::XServiceInfo >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< lang::XTypeProvider >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< lang::XUnoTunnel >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeCompare >*)0);
+
+            return aTypeSequence;
+        }
+    };
+}
+
 uno::Sequence< uno::Type > SAL_CALL SvxUnoTextRange::getTypes()
     throw (uno::RuntimeException)
 {
-    if( maTypeSequence.getLength() == 0 )
-    {
-        maTypeSequence.realloc( 9 ); // !DANGER! keep this updated
-        uno::Type* pTypes = maTypeSequence.getArray();
-
-        *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRange >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertySet >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertySet >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertyStates >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertyState >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< lang::XServiceInfo >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< lang::XTypeProvider >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< lang::XUnoTunnel >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeCompare >*)0);
-    }
-    return maTypeSequence;
+    return theSvxUnoTextRangeTypes::get();
 }
 
 uno::Sequence< sal_Int8 > SAL_CALL SvxUnoTextRange::getImplementationId()
@@ -1637,10 +1648,6 @@ OUString SAL_CALL SvxUnoTextRange::getImplementationName()
 // class SvxUnoText
 // ====================================================================
 
-// UNO3_GETIMPLEMENTATION2_IMPL( SvxUnoText, SvxUnoTextRangeBase );
-
-uno::Sequence< uno::Type > SvxUnoTextBase::maTypeSequence;
-
 SvxUnoTextBase::SvxUnoTextBase() throw()
 : SvxUnoTextRangeBase( NULL )
 {
@@ -1732,30 +1739,41 @@ uno::Any SAL_CALL SvxUnoTextBase::queryAggregation( const uno::Type & rType )
 
 // XTypeProvider
 
-uno::Sequence< uno::Type > SAL_CALL SvxUnoTextBase::getStaticTypes() throw()
+namespace
 {
-    if( maTypeSequence.getLength() == 0 )
+    struct theSvxUnoTextBaseTypes :
+        public rtl::StaticWithInit<uno::Sequence<uno::Type>, theSvxUnoTextBaseTypes>
     {
-        maTypeSequence.realloc( 15 ); // !DANGER! keep this updated
-        uno::Type* pTypes = maTypeSequence.getArray();
-
-        *pTypes++ = ::getCppuType(( const uno::Reference< text::XText >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< container::XEnumerationAccess >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertySet >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertySet >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertyStates >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertyState >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeMover >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextAppend >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextCopy >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< text::XParagraphAppend >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextPortionAppend >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< lang::XServiceInfo >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< lang::XTypeProvider >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< lang::XUnoTunnel >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeCompare >*)0);
-    }
-    return maTypeSequence;
+        uno::Sequence<uno::Type> operator () ()
+        {
+            uno::Sequence< uno::Type > aTypeSequence;
+
+            aTypeSequence.realloc( 15 ); // !DANGER! keep this updated
+            uno::Type* pTypes = aTypeSequence.getArray();
+
+            *pTypes++ = ::getCppuType(( const uno::Reference< text::XText >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< container::XEnumerationAccess >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertySet >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertySet >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertyStates >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertyState >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeMover >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextAppend >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextCopy >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< text::XParagraphAppend >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextPortionAppend >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< lang::XServiceInfo >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< lang::XTypeProvider >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< lang::XUnoTunnel >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeCompare >*)0);
+
+            return aTypeSequence;
+        }
+    };
+}
+uno::Sequence< uno::Type > SAL_CALL SvxUnoTextBase::getStaticTypes() throw()
+{
+    return theSvxUnoTextBaseTypes::get();
 }
 
 uno::Sequence< uno::Type > SAL_CALL SvxUnoTextBase::getTypes()
diff --git a/editeng/source/uno/unotext2.cxx b/editeng/source/uno/unotext2.cxx
index 7e94aac..f715c8e 100755
--- a/editeng/source/uno/unotext2.cxx
+++ b/editeng/source/uno/unotext2.cxx
@@ -36,6 +36,7 @@
 
 #include <rtl/uuid.h>
 #include <rtl/memory.h>
+#include <rtl/instance.hxx>
 
 #include <editeng/eeitem.hxx>
 #include <editeng/flditem.hxx>
@@ -113,7 +114,6 @@ uno::Any SvxUnoTextContentEnumeration::nextElement(void) throw( container::NoSuc
 // class SvxUnoTextContent
 // ====================================================================
 uno::Reference< text::XText > xDummyText;
-uno::Sequence< uno::Type > SvxUnoTextContent::maTypeSequence;
 
 static SvxUnoText* getDummyText() throw()
 {
@@ -200,27 +200,39 @@ void SAL_CALL SvxUnoTextContent::release() throw( )
 
 // XTypeProvider
 
+namespace
+{
+    struct theSvxUnoTextContentTypes :
+        public rtl::StaticWithInit<uno::Sequence<uno::Type>, theSvxUnoTextContentTypes>
+    {
+        uno::Sequence<uno::Type> operator () ()
+        {
+            uno::Sequence< uno::Type > aTypeSequence;
+
+            aTypeSequence.realloc( 11 ); // !DANGER! keep this updated
+            uno::Type* pTypes = aTypeSequence.getArray();
+
+            *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRange >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertySet >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertySet >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertyStates >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertyState >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeCompare >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextContent >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< container::XEnumerationAccess >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< lang::XServiceInfo >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< lang::XTypeProvider >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< lang::XUnoTunnel >*)0);
+
+            return aTypeSequence;
+        }
+    };
+}
+
 uno::Sequence< uno::Type > SAL_CALL SvxUnoTextContent::getTypes()
     throw (uno::RuntimeException)
 {
-    if( maTypeSequence.getLength() == 0 )
-    {
-        maTypeSequence.realloc( 11 ); // !DANGER! keep this updated
-        uno::Type* pTypes = maTypeSequence.getArray();
-
-        *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRange >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertySet >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertySet >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertyStates >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertyState >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeCompare >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextContent >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< container::XEnumerationAccess >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< lang::XServiceInfo >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< lang::XTypeProvider >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< lang::XUnoTunnel >*)0);
-    }
-    return maTypeSequence;
+    return theSvxUnoTextContentTypes::get();
 }
 
 uno::Sequence< sal_Int8 > SAL_CALL SvxUnoTextContent::getImplementationId()
@@ -487,8 +499,6 @@ uno::Any SAL_CALL SvxUnoTextRangeEnumeration::nextElement()
 // class SvxUnoTextCursor
 // ====================================================================
 
-uno::Sequence< uno::Type > SvxUnoTextCursor::maTypeSequence;
-
 uno::Reference< uno::XInterface > SvxUnoTextCursor_NewInstance()
 {
     SvxUnoText aText;
@@ -553,27 +563,39 @@ void SAL_CALL SvxUnoTextCursor::release() throw ( )
     OWeakAggObject::release();
 }
 
+namespace
+{
+    struct theSvxUnoTextCursorTypes :
+        public rtl::StaticWithInit<uno::Sequence<uno::Type>, theSvxUnoTextCursorTypes>
+    {
+        uno::Sequence<uno::Type> operator () ()
+        {
+            uno::Sequence< uno::Type > aTypeSequence;
+
+            aTypeSequence.realloc( 10 ); // !DANGER! keep this updated
+            uno::Type* pTypes = aTypeSequence.getArray();
+
+            *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRange >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextCursor >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertySet >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertySet >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertyStates >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertyState >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeCompare >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< lang::XServiceInfo >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< lang::XTypeProvider >*)0);
+            *pTypes++ = ::getCppuType(( const uno::Reference< lang::XUnoTunnel >*)0);
+
+            return aTypeSequence;
+        }
+    };
+}
+
 // XTypeProvider
 uno::Sequence< uno::Type > SAL_CALL SvxUnoTextCursor::getTypes()
     throw(uno::RuntimeException)
 {
-    if( maTypeSequence.getLength() == 0 )
-    {
-        maTypeSequence.realloc( 10 ); // !DANGER! keep this updated
-        uno::Type* pTypes = maTypeSequence.getArray();
-
-        *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRange >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextCursor >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertySet >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertySet >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< beans::XMultiPropertyStates >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< beans::XPropertyState >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< text::XTextRangeCompare >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< lang::XServiceInfo >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< lang::XTypeProvider >*)0);
-        *pTypes++ = ::getCppuType(( const uno::Reference< lang::XUnoTunnel >*)0);
-    }
-    return maTypeSequence;
+    return theSvxUnoTextCursorTypes::get();
 }
 
 uno::Sequence< sal_Int8 > SAL_CALL SvxUnoTextCursor::getImplementationId()


More information about the Libreoffice-commits mailing list