[Libreoffice-commits] core.git: Branch 'libreoffice-4-3' - 2 commits - basic/source desktop/Library_sofficeapp.mk desktop/source include/basic unotest/Library_unotest.mk unotest/source

Kohei Yoshida kohei.yoshida at collabora.com
Thu May 29 19:00:45 PDT 2014


 basic/source/classes/sb.cxx                 |   20 ++++++++++++++++++--
 basic/source/classes/sbunoobj.cxx           |   26 +++++++++++++++++++-------
 desktop/Library_sofficeapp.mk               |    1 +
 desktop/source/app/app.cxx                  |    2 ++
 include/basic/sbstar.hxx                    |    2 ++
 unotest/Library_unotest.mk                  |    1 +
 unotest/source/cpp/bootstrapfixturebase.cxx |    2 ++
 7 files changed, 45 insertions(+), 9 deletions(-)

New commits:
commit 9832a2482f157d34f7323327dc20eaf5e11da3fd
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Wed May 28 22:33:29 2014 -0400

    Detach all DocBasicItem objects upon process termination.
    
    To prevent rogue DocBasicItem objects (which are global objects) from
    attempting to stop listening after the main app is dead.
    
    Change-Id: I68a667137ca4e0eff18278f4d2d5dd67466eaf34
    (cherry picked from commit a916b6ff7fdf1bcb1182e72e4a5bf2f901c698da)

diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx
index 3d38428..922df3e 100644
--- a/basic/source/classes/sb.cxx
+++ b/basic/source/classes/sb.cxx
@@ -80,6 +80,11 @@ public:
     void startListening();
     void stopListening();
 
+    void setDisposed( bool bDisposed )
+    {
+        mbDisposed = bDisposed;
+    }
+
     virtual void SAL_CALL queryClosing( const lang::EventObject& rSource, sal_Bool bGetsOwnership ) throw (util::CloseVetoException, uno::RuntimeException, std::exception) SAL_OVERRIDE;
     virtual void SAL_CALL notifyClosing( const lang::EventObject& rSource ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
     virtual void SAL_CALL disposing( const lang::EventObject& rSource ) throw (uno::RuntimeException, std::exception) SAL_OVERRIDE;
@@ -2007,7 +2012,16 @@ Reference< frame::XModel > StarBASIC::GetModelFromBasic( SbxObject* pBasic )
     return xModel;
 }
 
-
+void StarBASIC::DetachAllDocBasicItems()
+{
+    DocBasicItemMap& rItems = GaDocBasicItems::get();
+    DocBasicItemMap::iterator it = rItems.begin(), itEnd = rItems.end();
+    for (; it != itEnd; ++it)
+    {
+        DocBasicItemRef xItem = it->second;
+        xItem->setDisposed(true);
+    }
+}
 
 // #118116 Implementation Collection object
 
diff --git a/desktop/Library_sofficeapp.mk b/desktop/Library_sofficeapp.mk
index 0c6c3e7..01950fc 100644
--- a/desktop/Library_sofficeapp.mk
+++ b/desktop/Library_sofficeapp.mk
@@ -39,6 +39,7 @@ $(eval $(call gb_Library_use_libraries,sofficeapp,\
     i18nlangtag \
     sal \
     salhelper \
+    sb \
     sfx \
     svl \
     svt \
diff --git a/desktop/source/app/app.cxx b/desktop/source/app/app.cxx
index bb14e03..9fa787c 100644
--- a/desktop/source/app/app.cxx
+++ b/desktop/source/app/app.cxx
@@ -98,6 +98,7 @@
 #include <sfx2/app.hxx>
 #include <svl/itemset.hxx>
 #include <svl/eitem.hxx>
+#include <basic/sbstar.hxx>
 
 #include <svtools/fontsubstconfig.hxx>
 #include <svtools/accessibilityoptions.hxx>
@@ -1766,6 +1767,7 @@ int Desktop::doShutdown()
     // with the solar mutex unlocked, to avoid deadlock:
     sal_uLong nAcquireCount = Application::ReleaseSolarMutex();
     DeregisterServices();
+    StarBASIC::DetachAllDocBasicItems();
     Application::AcquireSolarMutex(nAcquireCount);
     // be sure that path/language options gets destroyed before
     // UCB is deinitialized
diff --git a/include/basic/sbstar.hxx b/include/basic/sbstar.hxx
index 2eec72b..cb1d49a 100644
--- a/include/basic/sbstar.hxx
+++ b/include/basic/sbstar.hxx
@@ -174,6 +174,8 @@ public:
 
     static ::com::sun::star::uno::Reference< ::com::sun::star::frame::XModel >
         GetModelFromBasic( SbxObject* pBasic );
+
+    static void DetachAllDocBasicItems();
 };
 
 typedef tools::SvRef<StarBASIC> StarBASICRef;
diff --git a/unotest/Library_unotest.mk b/unotest/Library_unotest.mk
index cfc6fc1..3f9d99b 100644
--- a/unotest/Library_unotest.mk
+++ b/unotest/Library_unotest.mk
@@ -21,6 +21,7 @@ $(eval $(call gb_Library_use_libraries,unotest,\
 	cppu \
 	cppuhelper \
 	sal \
+	sb \
 	$(gb_UWINAPI) \
 ))
 
diff --git a/unotest/source/cpp/bootstrapfixturebase.cxx b/unotest/source/cpp/bootstrapfixturebase.cxx
index 87a72a7..c407dc6 100644
--- a/unotest/source/cpp/bootstrapfixturebase.cxx
+++ b/unotest/source/cpp/bootstrapfixturebase.cxx
@@ -15,6 +15,7 @@
 #include <rtl/bootstrap.hxx>
 #include <cppuhelper/bootstrap.hxx>
 #include <comphelper/processfactory.hxx>
+#include <basic/sbstar.hxx>
 
 #include <com/sun/star/lang/Locale.hpp>
 #include <com/sun/star/lang/XComponent.hpp>
@@ -105,6 +106,7 @@ void test::BootstrapFixtureBase::setUp()
 
 void test::BootstrapFixtureBase::tearDown()
 {
+    StarBASIC::DetachAllDocBasicItems();
 }
 
 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
commit ad9e67a7c08f9ceb3b4c228e3d9241c4ed54a7c8
Author: Kohei Yoshida <kohei.yoshida at collabora.com>
Date:   Wed May 28 20:54:50 2014 -0400

    Avoid static local of a singleton.  This crashed writer unit tests.
    
    Change-Id: I7c5f2d372676cdb317a8dad636bf1aab7dd5db37
    (cherry picked from commit 5a827671d16ff5e927fc3dd4a01e6c32ea05d891)

diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx
index 5a37bbc..3d38428 100644
--- a/basic/source/classes/sb.cxx
+++ b/basic/source/classes/sb.cxx
@@ -128,7 +128,9 @@ void DocBasicItem::stopListening()
     if( mbDisposed ) return;
     mbDisposed = true;
     Any aThisComp;
-    mrDocBasic.GetUNOConstant( "ThisComponent", aThisComp );
+    if (!mrDocBasic.GetUNOConstant("ThisComponent", aThisComp))
+        return;
+
     Reference< util::XCloseBroadcaster > xCloseBC( aThisComp, UNO_QUERY );
     if( xCloseBC.is() )
     {
diff --git a/basic/source/classes/sbunoobj.cxx b/basic/source/classes/sbunoobj.cxx
index 85343b2..56d1024 100644
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -2445,19 +2445,31 @@ SbUnoObject::~SbUnoObject()
 // pass the introspection on Demand
 void SbUnoObject::doIntrospection( void )
 {
-    static Reference< XIntrospection > xIntrospection;
-
     if( !bNeedIntrospection )
         return;
-    bNeedIntrospection = false;
 
-    if( !xIntrospection.is() )
+    Reference<XComponentContext> xContext = comphelper::getProcessComponentContext();
+
+    if (!xContext.is())
+        return;
+
+
+    // get the introspection service
+    Reference<XIntrospection> xIntrospection;
+
+    try
+    {
+        xIntrospection = theIntrospection::get(xContext);
+    }
+    catch ( const css::uno::DeploymentException& ex )
     {
-        // get the introspection service
-        Reference< XComponentContext > xContext( comphelper::getProcessComponentContext() );
-        xIntrospection = theIntrospection::get( xContext );
     }
 
+    if (!xIntrospection.is())
+        return;
+
+    bNeedIntrospection = false;
+
     // pass the introspection
     try
     {


More information about the Libreoffice-commits mailing list