summaryrefslogtreecommitdiff
path: root/include/comphelper
diff options
context:
space:
mode:
authorNoel Grandin <noel.grandin@collabora.co.uk>2023-02-14 13:14:14 +0200
committerNoel Grandin <noel.grandin@collabora.co.uk>2023-02-14 16:57:09 +0000
commit0e6e0270d25c4181ed15bd04123e20672f1e3a0b (patch)
tree08a1fdfa9601d13698f680a58f8a5641690f48db /include/comphelper
parentb429ca9b45b897da4c47a261ff582b536f27acd6 (diff)
no need to use unique_ptr for OInterfaceContainerHelper4
it has an empty size of one pointer, so it saves no memory to use unique_ptr. Need to fix the const-ness of some methods in OInterfaceContainerHelper4 Change-Id: I0c0c28a228ccfe0e97174fbc83555059fc351b3c Reviewed-on: https://gerrit.libreoffice.org/c/core/+/147007 Tested-by: Jenkins Reviewed-by: Noel Grandin <noel.grandin@collabora.co.uk>
Diffstat (limited to 'include/comphelper')
-rw-r--r--include/comphelper/interfacecontainer4.hxx13
1 files changed, 7 insertions, 6 deletions
diff --git a/include/comphelper/interfacecontainer4.hxx b/include/comphelper/interfacecontainer4.hxx
index 7f6e72bf91f1..3a6696fda8c5 100644
--- a/include/comphelper/interfacecontainer4.hxx
+++ b/include/comphelper/interfacecontainer4.hxx
@@ -200,7 +200,7 @@ public:
this parameter only here to make that this container is accessed while locked
*/
template <typename FuncT>
- inline void forEach(std::unique_lock<std::mutex>& rGuard, FuncT const& func);
+ inline void forEach(std::unique_lock<std::mutex>& rGuard, FuncT const& func) const;
/** Calls a UNO listener method for each contained listener.
@@ -227,7 +227,7 @@ public:
template <typename EventT>
inline void notifyEach(std::unique_lock<std::mutex>& rGuard,
void (SAL_CALL ListenerT::*NotificationMethod)(const EventT&),
- const EventT& Event);
+ const EventT& Event) const;
private:
friend class OInterfaceIteratorHelper4<ListenerT>;
@@ -279,14 +279,15 @@ inline OInterfaceContainerHelper4<T>::OInterfaceContainerHelper4()
template <class T>
template <typename FuncT>
inline void OInterfaceContainerHelper4<T>::forEach(std::unique_lock<std::mutex>& rGuard,
- FuncT const& func)
+ FuncT const& func) const
{
if (std::as_const(maData)->size() == 0)
{
return;
}
- maData.make_unique(); // so we can iterate over the data without holding the lock
- OInterfaceIteratorHelper4<T> iter(rGuard, *this);
+ const_cast<OInterfaceContainerHelper4&>(*this)
+ .maData.make_unique(); // so we can iterate over the data without holding the lock
+ OInterfaceIteratorHelper4<T> iter(rGuard, const_cast<OInterfaceContainerHelper4&>(*this));
rGuard.unlock();
while (iter.hasMoreElements())
{
@@ -312,7 +313,7 @@ template <class ListenerT>
template <typename EventT>
inline void OInterfaceContainerHelper4<ListenerT>::notifyEach(
std::unique_lock<std::mutex>& rGuard,
- void (SAL_CALL ListenerT::*NotificationMethod)(const EventT&), const EventT& Event)
+ void (SAL_CALL ListenerT::*NotificationMethod)(const EventT&), const EventT& Event) const
{
forEach<NotifySingleListener<EventT>>(rGuard,
NotifySingleListener<EventT>(NotificationMethod, Event));