From 8b960f0ec4ac13a98d8b1c33cf23ef82cc5b6841 Mon Sep 17 00:00:00 2001 From: Stephan Bergmann Date: Thu, 23 Feb 2012 10:45:37 +0100 Subject: Adapted LateInitThread to safer-to-use salhelper::Thread --- filter/Library_filterconfig.mk | 1 + filter/prj/build.lst | 2 +- filter/source/config/cache/lateinitlistener.cxx | 15 ++++--- filter/source/config/cache/lateinitthread.cxx | 49 +++++---------------- filter/source/config/cache/lateinitthread.hxx | 58 ++++++------------------- 5 files changed, 36 insertions(+), 89 deletions(-) diff --git a/filter/Library_filterconfig.mk b/filter/Library_filterconfig.mk index 13847806eb9b..39346e70944a 100644 --- a/filter/Library_filterconfig.mk +++ b/filter/Library_filterconfig.mk @@ -39,6 +39,7 @@ $(eval $(call gb_Library_add_linked_libs,filterconfig,\ cppuhelper \ cppu \ sal \ + salhelper \ $(gb_STDLIBS) \ )) diff --git a/filter/prj/build.lst b/filter/prj/build.lst index 76713fe09885..9083dc77766a 100644 --- a/filter/prj/build.lst +++ b/filter/prj/build.lst @@ -1,2 +1,2 @@ -fl filter : TRANSLATIONS:translations svtools unotools xmloff cppu tools cppuhelper sal svx javaunohelper XPDF:xpdf jvmaccess canvas SAXON:saxon LIBXSLT:libxslt basegfx package PYTHON:python NULL +fl filter : TRANSLATIONS:translations svtools unotools xmloff cppu tools cppuhelper sal salhelper svx javaunohelper XPDF:xpdf jvmaccess canvas SAXON:saxon LIBXSLT:libxslt basegfx package PYTHON:python NULL fl filter\prj nmake - all fl_prj NULL diff --git a/filter/source/config/cache/lateinitlistener.cxx b/filter/source/config/cache/lateinitlistener.cxx index 1179bf5bdc1c..3d4492206b5c 100644 --- a/filter/source/config/cache/lateinitlistener.cxx +++ b/filter/source/config/cache/lateinitlistener.cxx @@ -26,14 +26,14 @@ * ************************************************************************/ +#include "sal/config.h" + +#include "rtl/ref.hxx" +#include "rtl/ustring.hxx" #include "lateinitlistener.hxx" #include "lateinitthread.hxx" -//_______________________________________________ -// includes -#include - //_______________________________________________ // namespace @@ -110,8 +110,11 @@ void SAL_CALL LateInitListener::notifyEvent(const css::document::EventObject& aE if (!aEvent.EventName.equalsAsciiL(RTL_CONSTASCII_STRINGPARAM("OnCloseApp"))) { - LateInitThread* pThread = new LateInitThread(); - pThread->create(); + rtl::Reference< LateInitThread >(new LateInitThread())->launch(); + //TODO: a protocol is missing how to join with the launched + // thread before exit(3), to ensure the thread is no longer + // relying on any infrastructure while that infrastructure is + // being shut down in atexit handlers } } } diff --git a/filter/source/config/cache/lateinitthread.cxx b/filter/source/config/cache/lateinitthread.cxx index 61c066cd7dd8..80b9348b9b48 100644 --- a/filter/source/config/cache/lateinitthread.cxx +++ b/filter/source/config/cache/lateinitthread.cxx @@ -26,40 +26,21 @@ * ************************************************************************/ +#include "sal/config.h" -#include "lateinitthread.hxx" - -//_______________________________________________ -// includes - -//_______________________________________________ -// namespace - -namespace filter{ - namespace config{ - -namespace css = ::com::sun::star; - -//_______________________________________________ -// definitions - - - -LateInitThread::LateInitThread() -{ -} +#include "salhelper/singletonref.hxx" +#include "filtercache.hxx" +#include "lateinitthread.hxx" +namespace filter { namespace config { -LateInitThread::~LateInitThread() -{ -} +LateInitThread::LateInitThread(): Thread("lateinitthread") {} +LateInitThread::~LateInitThread() {} - -void SAL_CALL LateInitThread::run() -{ - // sal_True => It indicates using of this method by this thread +void LateInitThread::execute() { + // true => It indicates using of this method by this thread // The filter cache use this information to show an assertion // for "optimization failure" in case the first calli of loadAll() // was not this thread ... @@ -68,16 +49,10 @@ void SAL_CALL LateInitThread::run() // May be they show the problem of a corrupted filter // configuration, which is handled inside our event loop or desktop.main()! - ::salhelper::SingletonRef< FilterCache > rCache; - rCache->load(FilterCache::E_CONTAINS_ALL, sal_True); -} - -void SAL_CALL LateInitThread::onTerminated() -{ - delete this; + salhelper::SingletonRef< FilterCache >()->load( + FilterCache::E_CONTAINS_ALL, true); } - } // namespace config -} // namespace filter +} } /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ diff --git a/filter/source/config/cache/lateinitthread.hxx b/filter/source/config/cache/lateinitthread.hxx index 98c59b00972b..3ade96ff4e8b 100644 --- a/filter/source/config/cache/lateinitthread.hxx +++ b/filter/source/config/cache/lateinitthread.hxx @@ -26,26 +26,14 @@ * ************************************************************************/ -#ifndef __FILTER_CONFIG_LATEINITTHREAD_HXX_ -#define __FILTER_CONFIG_LATEINITTHREAD_HXX_ +#ifndef INCLUDED_FILTER_SOURCE_CONFIG_CACHE_LATEINITTHREAD_HXX +#define INCLUDED_FILTER_SOURCE_CONFIG_CACHE_LATEINITTHREAD_HXX -//_______________________________________________ -// includes +#include "sal/config.h" -#include "filtercache.hxx" -#include -#include +#include "salhelper/thread.hxx" -//_______________________________________________ -// namespace - -namespace filter{ - namespace config{ - -//_______________________________________________ -// definitions - -//_______________________________________________ +namespace filter{ namespace config { /** @short implements a thread, which will update the global filter cache of an office, after its @@ -57,38 +45,18 @@ namespace filter{ @attention The filter cache will be blocked during this thrad runs! */ -class LateInitThread : public ::osl::Thread -{ - //------------------------------------------- - // native interface - - public: - - //--------------------------------------- - // ctor/dtor - - /** @short initialize new instance of this class. - */ - LateInitThread(); - - //--------------------------------------- - - /** @short standard dtor. - */ - virtual ~LateInitThread(); - - //--------------------------------------- +class LateInitThread: public salhelper::Thread { +public: + LateInitThread(); - /** @short thread function. - */ - virtual void SAL_CALL run(); +private: + virtual ~LateInitThread(); - virtual void SAL_CALL onTerminated(); + virtual void execute(); }; - } // namespace config -} // namespace filter +} } -#endif // __FILTER_CONFIG_LATEINITTHREAD_HXX_ +#endif /* vim:set shiftwidth=4 softtabstop=4 expandtab: */ -- cgit