summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2022-05-24 14:06:51 +0200
committerStephan Bergmann <sbergman@redhat.com>2022-05-24 21:17:58 +0200
commitc022b7a169eebf15f38db0286660ac84cc537358 (patch)
treeb6a888b010824891c9e6bf219ce00fa1d807ee71
parentd07acfc4b2cc92d094d8eac204868e26c9e25e27 (diff)
fix thread-safety in OInterfaceContainerHelper4
we need thread-safety here (even though we use a mutex), because we use a singleton, and the singleton can be ref-counted when the OInterfaceContainerHelper4 is deleted, and is generallly not held at that point, and that is tricky to enforce. Change-Id: I1d61495786d5f0e18deae724b2eb6c6645feb51a Reviewed-on: https://gerrit.libreoffice.org/c/core/+/134872 Tested-by: Jenkins Reviewed-by: Stephan Bergmann <sbergman@redhat.com>
-rw-r--r--include/comphelper/interfacecontainer4.hxx16
1 files changed, 12 insertions, 4 deletions
diff --git a/include/comphelper/interfacecontainer4.hxx b/include/comphelper/interfacecontainer4.hxx
index fe19bab4e43e..694e5b17bbca 100644
--- a/include/comphelper/interfacecontainer4.hxx
+++ b/include/comphelper/interfacecontainer4.hxx
@@ -86,7 +86,9 @@ public:
private:
OInterfaceContainerHelper4<ListenerT>& rCont;
- o3tl::cow_wrapper<std::vector<css::uno::Reference<ListenerT>>> maData;
+ o3tl::cow_wrapper<std::vector<css::uno::Reference<ListenerT>>,
+ o3tl::ThreadSafeRefCountingPolicy>
+ maData;
sal_Int32 nRemain;
OInterfaceIteratorHelper4(const OInterfaceIteratorHelper4&) = delete;
@@ -228,13 +230,19 @@ public:
private:
friend class OInterfaceIteratorHelper4<ListenerT>;
- o3tl::cow_wrapper<std::vector<css::uno::Reference<ListenerT>>> maData;
+ o3tl::cow_wrapper<std::vector<css::uno::Reference<ListenerT>>,
+ o3tl::ThreadSafeRefCountingPolicy>
+ maData;
OInterfaceContainerHelper4(const OInterfaceContainerHelper4&) = delete;
OInterfaceContainerHelper4& operator=(const OInterfaceContainerHelper4&) = delete;
- static o3tl::cow_wrapper<std::vector<css::uno::Reference<ListenerT>>>& DEFAULT()
+ static o3tl::cow_wrapper<std::vector<css::uno::Reference<ListenerT>>,
+ o3tl::ThreadSafeRefCountingPolicy>&
+ DEFAULT()
{
- static o3tl::cow_wrapper<std::vector<css::uno::Reference<ListenerT>>> SINGLETON;
+ static o3tl::cow_wrapper<std::vector<css::uno::Reference<ListenerT>>,
+ o3tl::ThreadSafeRefCountingPolicy>
+ SINGLETON;
return SINGLETON;
}