From a916b6ff7fdf1bcb1182e72e4a5bf2f901c698da Mon Sep 17 00:00:00 2001 From: Kohei Yoshida Date: Wed, 28 May 2014 22:33:29 -0400 Subject: 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 --- basic/source/classes/sb.cxx | 16 +++++++++++++++- 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 ++ 6 files changed, 23 insertions(+), 1 deletion(-) diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx index 3d3842840b32..922df3e82b8e 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 0c6c3e71f0ba..01950fcc5b0a 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 290312d9b0e4..b6c4e8c1cdbb 100644 --- a/desktop/source/app/app.cxx +++ b/desktop/source/app/app.cxx @@ -98,6 +98,7 @@ #include #include #include +#include #include #include @@ -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 2eec72bae613..cb1d49a72bf4 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 StarBASICRef; diff --git a/unotest/Library_unotest.mk b/unotest/Library_unotest.mk index cfc6fc197002..3f9d99b6f0a3 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 87a72a725eb0..c407dc677b20 100644 --- a/unotest/source/cpp/bootstrapfixturebase.cxx +++ b/unotest/source/cpp/bootstrapfixturebase.cxx @@ -15,6 +15,7 @@ #include #include #include +#include #include #include @@ -105,6 +106,7 @@ void test::BootstrapFixtureBase::setUp() void test::BootstrapFixtureBase::tearDown() { + StarBASIC::DetachAllDocBasicItems(); } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit