summaryrefslogtreecommitdiff
path: root/framework
diff options
context:
space:
mode:
authorNoel Grandin <noelgrandin@gmail.com>2021-03-21 13:41:39 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2021-03-23 09:33:43 +0100
commita9493229bb453a8f437c45d838777e2ba8217b76 (patch)
tree001b5fb384cb4cb9f7ff376ba4d980bed08d1c2d /framework
parentdb39b68c3c85531744ddeb8105b3ddb9b2dab099 (diff)
use single-use attribute for ContextChangeEventMultiplexer
instead of rtl::Instance, which means it will get cleaned up when UNO shuts down Change-Id: I13b36f1fe570f789036ef54ecfb7d0a85ce1450c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112842 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'framework')
-rw-r--r--framework/inc/helper/mischelper.hxx2
-rw-r--r--framework/source/fwe/classes/sfxhelperfunctions.cxx3
-rw-r--r--framework/source/fwi/helper/mischelper.cxx4
-rw-r--r--framework/source/services/ContextChangeEventMultiplexer.cxx24
-rw-r--r--framework/util/fwk.component3
5 files changed, 15 insertions, 21 deletions
diff --git a/framework/inc/helper/mischelper.hxx b/framework/inc/helper/mischelper.hxx
index 4dcb94003449..d05ae360a082 100644
--- a/framework/inc/helper/mischelper.hxx
+++ b/framework/inc/helper/mischelper.hxx
@@ -246,10 +246,12 @@ class WeakDocumentEventListener final : public ::cppu::WeakImplHelper<css::docum
css::uno::Reference<css::ui::XContextChangeEventListener>
GetFirstListenerWith_Impl(
+ css::uno::Reference<css::uno::XComponentContext> const & xComponentContext,
css::uno::Reference<css::uno::XInterface> const& xEventFocus,
std::function<bool (css::uno::Reference<css::ui::XContextChangeEventListener> const&)> const& rPredicate);
extern auto (*g_pGetMultiplexerListener)(
+ css::uno::Reference<css::uno::XComponentContext> const & xComponentContext,
css::uno::Reference<css::uno::XInterface> const&,
std::function<bool (css::uno::Reference<css::ui::XContextChangeEventListener> const&)> const&)
-> css::uno::Reference<css::ui::XContextChangeEventListener>;
diff --git a/framework/source/fwe/classes/sfxhelperfunctions.cxx b/framework/source/fwe/classes/sfxhelperfunctions.cxx
index e456a7a42460..9adc5931a7e3 100644
--- a/framework/source/fwe/classes/sfxhelperfunctions.cxx
+++ b/framework/source/fwe/classes/sfxhelperfunctions.cxx
@@ -146,10 +146,11 @@ bool IsDockingWindowVisible( const css::uno::Reference< css::frame::XFrame >& rF
using namespace ::com::sun::star;
uno::Reference<ui::XContextChangeEventListener> GetFirstListenerWith(
+ css::uno::Reference<css::uno::XComponentContext> const & xComponentContext,
uno::Reference<uno::XInterface> const& xEventFocus,
std::function<bool (uno::Reference<ui::XContextChangeEventListener> const&)> const& rPredicate)
{
- return GetFirstListenerWith_Impl(xEventFocus, rPredicate);
+ return GetFirstListenerWith_Impl(xComponentContext, xEventFocus, rPredicate);
}
}
diff --git a/framework/source/fwi/helper/mischelper.cxx b/framework/source/fwi/helper/mischelper.cxx
index b53cd0f2672d..e9c664d474df 100644
--- a/framework/source/fwi/helper/mischelper.cxx
+++ b/framework/source/fwi/helper/mischelper.cxx
@@ -133,17 +133,19 @@ void FillLangItems( std::set< OUString > &rLangItems,
}
auto (*g_pGetMultiplexerListener)(
+ css::uno::Reference<css::uno::XComponentContext> const & xComponentContext,
uno::Reference<uno::XInterface> const&,
std::function<bool (uno::Reference<ui::XContextChangeEventListener> const&)> const&)
-> uno::Reference<ui::XContextChangeEventListener> = nullptr;
uno::Reference<ui::XContextChangeEventListener>
GetFirstListenerWith_Impl(
+ css::uno::Reference<css::uno::XComponentContext> const & xComponentContext,
uno::Reference<uno::XInterface> const& xEventFocus,
std::function<bool (uno::Reference<ui::XContextChangeEventListener> const&)> const& rPredicate)
{
assert(g_pGetMultiplexerListener != nullptr); // should not be called too early, nor too late
- return g_pGetMultiplexerListener(xEventFocus, rPredicate);
+ return g_pGetMultiplexerListener(xComponentContext, xEventFocus, rPredicate);
}
diff --git a/framework/source/services/ContextChangeEventMultiplexer.cxx b/framework/source/services/ContextChangeEventMultiplexer.cxx
index fe24c2b6d770..3e647985cb40 100644
--- a/framework/source/services/ContextChangeEventMultiplexer.cxx
+++ b/framework/source/services/ContextChangeEventMultiplexer.cxx
@@ -23,11 +23,13 @@
#include <com/sun/star/lang/XEventListener.hpp>
#include <com/sun/star/lang/XServiceInfo.hpp>
#include <com/sun/star/ui/XContextChangeEventMultiplexer.hpp>
+#include <com/sun/star/ui/ContextChangeEventMultiplexer.hpp>
#include <com/sun/star/uno/XComponentContext.hpp>
#include <cppuhelper/compbase.hxx>
#include <cppuhelper/supportsservice.hxx>
#include <cppuhelper/basemutex.hxx>
+#include <rtl/ref.hxx>
#include <algorithm>
#include <map>
@@ -324,34 +326,21 @@ void SAL_CALL ContextChangeEventMultiplexer::disposing ( const css::lang::EventO
maListeners.erase(iDescriptor);
}
-struct Instance {
- explicit Instance():
- instance(static_cast<cppu::OWeakObject *>(
- new ContextChangeEventMultiplexer()))
- {
- }
-
- css::uno::Reference<css::uno::XInterface> instance;
-};
-
-struct Singleton:
- public rtl::Static<Instance, Singleton>
-{};
-
}
namespace framework {
// right now we assume there's one matching listener
static uno::Reference<ui::XContextChangeEventListener> GetFirstListenerWith_ImplImpl(
+ css::uno::Reference<css::uno::XComponentContext> const & xComponentContext,
uno::Reference<uno::XInterface> const& xEventFocus,
std::function<bool (uno::Reference<ui::XContextChangeEventListener> const&)> const& rPredicate)
{
assert(xEventFocus.is()); // in current usage it's a bug if the XController is null here
uno::Reference<ui::XContextChangeEventListener> xRet;
- ContextChangeEventMultiplexer *const pMultiplexer(
- dynamic_cast<ContextChangeEventMultiplexer *>(Singleton::get().instance.get()));
+ rtl::Reference<ContextChangeEventMultiplexer> pMultiplexer =
+ dynamic_cast<ContextChangeEventMultiplexer *>(ui::ContextChangeEventMultiplexer::get(xComponentContext).get());
assert(pMultiplexer);
ContextChangeEventMultiplexer::FocusDescriptor const*const pFocusDescriptor(
@@ -389,8 +378,7 @@ org_apache_openoffice_comp_framework_ContextChangeEventMultiplexer_get_implement
css::uno::XComponentContext *,
css::uno::Sequence<css::uno::Any> const &)
{
- return cppu::acquire(static_cast<cppu::OWeakObject *>(
- Singleton::get().instance.get()));
+ return cppu::acquire(new ContextChangeEventMultiplexer());
}
/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/framework/util/fwk.component b/framework/util/fwk.component
index bb74eb817d12..2b9eb7807fee 100644
--- a/framework/util/fwk.component
+++ b/framework/util/fwk.component
@@ -47,7 +47,8 @@
<service name="com.sun.star.ui.DocumentAcceleratorConfiguration"/>
</implementation>
<implementation name="org.apache.openoffice.comp.framework.ContextChangeEventMultiplexer"
- constructor="org_apache_openoffice_comp_framework_ContextChangeEventMultiplexer_get_implementation">
+ constructor="org_apache_openoffice_comp_framework_ContextChangeEventMultiplexer_get_implementation"
+ single-instance="true">
<singleton name="com.sun.star.ui.ContextChangeEventMultiplexer"/>
</implementation>
<implementation name="com.sun.star.comp.framework.Frame"