diff options
-rw-r--r-- | comphelper/inc/comphelper/uieventslogger.hxx | 4 | ||||
-rw-r--r-- | comphelper/source/misc/uieventslogger.cxx | 51 |
2 files changed, 46 insertions, 9 deletions
diff --git a/comphelper/inc/comphelper/uieventslogger.hxx b/comphelper/inc/comphelper/uieventslogger.hxx index 5321d97c89bc..b7b1cc4cb9be 100644 --- a/comphelper/inc/comphelper/uieventslogger.hxx +++ b/comphelper/inc/comphelper/uieventslogger.hxx @@ -30,11 +30,8 @@ #ifndef _COMPHELPER_UIEVENTSLOGGER_HXX #define _COMPHELPER_UIEVENTSLOGGER_HXX -#include <boost/shared_ptr.hpp> #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/beans/PropertyValue.hpp> -#include <com/sun/star/logging/XCsvLogFormatter.hpp> -#include <com/sun/star/logging/XLogger.hpp> #include <com/sun/star/uno/Reference.hxx> #include <com/sun/star/util/URL.hpp> #include <comphelper/comphelperdllapi.h> @@ -55,6 +52,7 @@ namespace comphelper static void logVcl(const ::rtl::OUString& parent_id, sal_Int32 window_type, const ::rtl::OUString& id, const ::rtl::OUString& method, const ::rtl::OUString& param); static void logVcl(const ::rtl::OUString& parent_id, sal_Int32 window_type, const ::rtl::OUString& id, const ::rtl::OUString& method, sal_Int32 param); static void logVcl(const ::rtl::OUString& parent_id, sal_Int32 window_type, const ::rtl::OUString& id, const ::rtl::OUString& method); + static void disposing(); virtual ~UiEventsLogger() {} }; } diff --git a/comphelper/source/misc/uieventslogger.cxx b/comphelper/source/misc/uieventslogger.cxx index ab6f087fced7..a60ecc9058de 100644 --- a/comphelper/source/misc/uieventslogger.cxx +++ b/comphelper/source/misc/uieventslogger.cxx @@ -31,32 +31,39 @@ #include "precompiled_comphelper.hxx" #include <comphelper/uieventslogger.hxx> +#include <boost/shared_ptr.hpp> +#include <com/sun/star/frame/XDesktop.hpp> +#include <com/sun/star/frame/XTerminateListener.hpp> +#include <com/sun/star/lang/XEventListener.hpp> #include <com/sun/star/lang/XMultiComponentFactory.hpp> #include <com/sun/star/lang/XMultiServiceFactory.hpp> #include <com/sun/star/logging/LogLevel.hpp> +#include <com/sun/star/logging/XCsvLogFormatter.hpp> #include <com/sun/star/logging/XLogHandler.hpp> +#include <com/sun/star/logging/XLogger.hpp> #include <com/sun/star/logging/XLoggerPool.hpp> #include <com/sun/star/oooimprovement/XCoreController.hpp> #include <com/sun/star/uno/Sequence.hxx> #include <com/sun/star/util/XStringSubstitution.hpp> #include <comphelper/configurationhelper.hxx> #include <comphelper/processfactory.hxx> +#include <map> #include <osl/file.hxx> #include <osl/mutex.hxx> #include <osl/time.h> #include <rtl/ustrbuf.hxx> -#include <map> using namespace com::sun::star::beans; -using namespace com::sun::star::uno; +using namespace com::sun::star::frame; using namespace com::sun::star::lang; using namespace com::sun::star::logging; using namespace com::sun::star::oooimprovement; +using namespace com::sun::star::uno; using namespace com::sun::star::util; -using namespace rtl; using namespace cppu; using namespace osl; +using namespace rtl; using namespace std; @@ -102,7 +109,7 @@ namespace comphelper private: //typedefs and friends friend class UiEventsLogger; - typedef ::boost::shared_ptr<UiEventsLogger_Impl> ptr; + typedef UiEventsLogger_Impl* ptr; // instance methods and data UiEventsLogger_Impl(); @@ -121,6 +128,7 @@ namespace comphelper void checkIdleTimeout(); OUString getCurrentPath(); OUString getRotatedPath(); + void disposing(); bool m_Active; TimeValue m_LastLogEventTime; @@ -293,6 +301,12 @@ namespace comphelper UiEventsLogger::logVcl(parent_id, window_type, id, method, empty); } + void UiEventsLogger::disposing() + { + if(UiEventsLogger_Impl::instance!=UiEventsLogger_Impl::ptr()) + UiEventsLogger_Impl::instance->disposing(); + } + // private UiEventsLogger_Impl methods UiEventsLogger_Impl::UiEventsLogger_Impl() : m_Active(UiEventsLogger_Impl::shouldActivate()) @@ -311,9 +325,9 @@ namespace comphelper const URL& url, const Sequence<PropertyValue>& args) { + Guard<Mutex> log_guard(m_LogMutex); if(!m_Active) return; if(!url.Complete.match(URL_UNO) && !url.Complete.match(URL_FILE)) return; - Guard<Mutex> log_guard(m_LogMutex); checkIdleTimeout(); Sequence<OUString> logdata = Sequence<OUString>(COLUMNS); @@ -363,8 +377,8 @@ namespace comphelper const OUString& method, const OUString& param) { - if(!m_Active) return; Guard<Mutex> log_guard(m_LogMutex); + if(!m_Active) return; checkIdleTimeout(); OUStringBuffer buf; @@ -463,6 +477,22 @@ namespace comphelper { Reference<XMultiServiceFactory> sm = getProcessServiceFactory(); + // getting the Core Uno proxy object + // It will call disposing and make sure we clear all our references + { + Reference<XTerminateListener> xCore( + sm->createInstance(OUString::createFromAscii("com.sun.star.oooimprovement.Core")), + UNO_QUERY); + Reference<XDesktop> xDesktop( + sm->createInstance(OUString::createFromAscii("com.sun.star.frame.Desktop")), + UNO_QUERY); + if(!(xCore.is() && xDesktop.is())) + { + m_Active = false; + return; + } + xDesktop->addTerminateListener(xCore); + } // getting the LoggerPool Reference<XLoggerPool> pool; { @@ -592,4 +622,13 @@ namespace comphelper return i; return -1; } + + void UiEventsLogger_Impl::disposing() + { + Guard<Mutex> log_guard(m_LogMutex); + m_Active = false; + m_Logger.clear() ; + m_LogHandler.clear(); + m_Formatter.clear(); + } } |