sd/source/console/PresenterTimer.cxx | 32 +++++++++++--------------------- sd/source/console/PresenterTimer.hxx | 16 ++++++---------- 2 files changed, 17 insertions(+), 31 deletions(-)
New commits: commit da057720373060f90caedf79da698039500e580c Author: Noel Grandin <noelgran...@gmail.com> AuthorDate: Sat Jun 14 17:37:35 2025 +0200 Commit: Noel Grandin <noelgran...@gmail.com> CommitDate: Sun Jun 15 15:44:01 2025 +0200 no need to use the AsyncCallback wrapper here we can use the underlying vcl API Change-Id: I7c4987e5d12a0131e6556387c1e37c65c68cdae0 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/186509 Reviewed-by: Noel Grandin <noel.gran...@collabora.co.uk> Tested-by: Jenkins diff --git a/sd/source/console/PresenterTimer.cxx b/sd/source/console/PresenterTimer.cxx index a0fe450bd504..8ffa7ce53570 100644 --- a/sd/source/console/PresenterTimer.cxx +++ b/sd/source/console/PresenterTimer.cxx @@ -25,6 +25,7 @@ #include <osl/thread.hxx> #include <osl/conditn.hxx> +#include <vcl/svapp.hxx> #include <algorithm> #include <atomic> @@ -448,14 +449,6 @@ PresenterClockTimer::PresenterClockTimer (const Reference<XComponentContext>& rx m_xContext(rxContext) { assert(m_xContext.is()); - Reference<lang::XMultiComponentFactory> xFactory = - rxContext->getServiceManager(); - if (xFactory.is()) - mxRequestCallback.set( - xFactory->createInstanceWithContext( - u"com.sun.star.awt.AsyncCallback"_ustr, - rxContext), - UNO_QUERY_THROW); } PresenterClockTimer::~PresenterClockTimer() @@ -466,10 +459,8 @@ PresenterClockTimer::~PresenterClockTimer() mnTimerTaskId = PresenterTimer::NotAValidTaskId; } - Reference<lang::XComponent> xComponent (mxRequestCallback, UNO_QUERY); - if (xComponent.is()) - xComponent->dispose(); - mxRequestCallback = nullptr; + if (mpRequestCallbackId) + Application::RemoveUserEvent(mpRequestCallbackId); } void PresenterClockTimer::AddListener (const SharedListener& rListener) @@ -522,8 +513,7 @@ oslDateTime PresenterClockTimer::GetCurrentTime() void PresenterClockTimer::CheckCurrentTime (const TimeValue& rCurrentTime) { - css::uno::Reference<css::awt::XRequestCallback> xRequestCallback; - css::uno::Reference<css::awt::XCallback> xCallback; + bool bAddCallback = false; { std::unique_lock aGuard (maMutex); @@ -540,23 +530,23 @@ void PresenterClockTimer::CheckCurrentTime (const TimeValue& rCurrentTime) maDateTime = aDateTime; // Schedule notification of listeners. - if (mxRequestCallback.is() && ! mbIsCallbackPending) + if (! mbIsCallbackPending) { mbIsCallbackPending = true; - xRequestCallback = mxRequestCallback; - xCallback = this; + bAddCallback = true; } } } } - if (xRequestCallback.is() && xCallback.is()) - xRequestCallback->addCallback(xCallback, Any()); + if (bAddCallback) + mpRequestCallbackId = Application::PostUserEvent(LINK(this, PresenterClockTimer, HandleCall_PostUserEvent)); } -//----- XCallback ------------------------------------------------------------- -void SAL_CALL PresenterClockTimer::notify (const css::uno::Any&) +IMPL_LINK_NOARG( PresenterClockTimer, HandleCall_PostUserEvent, void*, void ) { + mpRequestCallbackId = nullptr; + ListenerContainer aListenerCopy; { diff --git a/sd/source/console/PresenterTimer.hxx b/sd/source/console/PresenterTimer.hxx index 8cba60a22346..7b022d6be1ea 100644 --- a/sd/source/console/PresenterTimer.hxx +++ b/sd/source/console/PresenterTimer.hxx @@ -20,13 +20,12 @@ #ifndef INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERTIMER_HXX #define INCLUDED_SDEXT_SOURCE_PRESENTER_PRESENTERTIMER_HXX -#include <com/sun/star/awt/XCallback.hpp> -#include <com/sun/star/awt/XRequestCallback.hpp> #include <cppuhelper/basemutex.hxx> #include <cppuhelper/compbase.hxx> #include <osl/time.h> #include <rtl/ref.hxx> #include <sal/types.h> +#include <tools/link.hxx> #include <functional> #include <memory> @@ -34,6 +33,7 @@ #include <vector> namespace com::sun::star::uno { class XComponentContext; } +struct ImplSVEvent; namespace sdext::presenter { @@ -63,9 +63,7 @@ public: static void CancelTask (const sal_Int32 nTaskId); }; -typedef cppu::WeakComponentImplHelper< - css::awt::XCallback - > PresenterClockTimerInterfaceBase; +typedef cppu::WeakComponentImplHelper<> PresenterClockTimerInterfaceBase; /** A timer that calls its listeners, typically clocks, every second to update their current time value. @@ -92,20 +90,18 @@ public: static oslDateTime GetCurrentTime(); - // XCallback - - virtual void SAL_CALL notify (const css::uno::Any& rUserData) override; - private: static ::rtl::Reference<PresenterClockTimer> mpInstance; + DECL_LINK( HandleCall_PostUserEvent, void*, void ); + std::mutex maMutex; typedef ::std::vector<SharedListener> ListenerContainer; ListenerContainer maListeners; oslDateTime maDateTime; sal_Int32 mnTimerTaskId; bool mbIsCallbackPending; - css::uno::Reference<css::awt::XRequestCallback> mxRequestCallback; + ImplSVEvent* mpRequestCallbackId { nullptr }; const css::uno::Reference<css::uno::XComponentContext> m_xContext; PresenterClockTimer (