From: Michael Friedrich Date: Wed, 11 Nov 2015 13:18:25 +0000 (+0100) Subject: Fix that custom attribute with function value cannot be cloned X-Git-Tag: v2.4.0~10 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=545607be9f632fa94c438f6a0db072558d97e0a7;p=icinga2 Fix that custom attribute with function value cannot be cloned fixes #10583 --- diff --git a/lib/base/dictionary.cpp b/lib/base/dictionary.cpp index a62bddb3d..1b54c57af 100644 --- a/lib/base/dictionary.cpp +++ b/lib/base/dictionary.cpp @@ -157,18 +157,18 @@ Dictionary::Ptr Dictionary::ShallowClone(void) const /** * Makes a deep clone of a dictionary * and its elements. - * + * * @returns a copy of the dictionary. */ Object::Ptr Dictionary::Clone(void) const { Dictionary::Ptr dict = new Dictionary(); - + ObjectLock olock(this); BOOST_FOREACH(const Dictionary::Pair& kv, m_Data) { dict->Set(kv.first, kv.second.Clone()); } - + return dict; } diff --git a/lib/base/function.cpp b/lib/base/function.cpp index 6d0e850a6..d327defde 100644 --- a/lib/base/function.cpp +++ b/lib/base/function.cpp @@ -39,3 +39,7 @@ bool Function::IsSideEffectFree(void) const return m_SideEffectFree; } +Object::Ptr Function::Clone(void) const +{ + return const_cast(this); +} diff --git a/lib/base/function.hpp b/lib/base/function.hpp index 5d912ca89..ff0d8b244 100644 --- a/lib/base/function.hpp +++ b/lib/base/function.hpp @@ -49,6 +49,8 @@ public: static Object::Ptr GetPrototype(void); + virtual Object::Ptr Clone(void) const override; + private: Callback m_Callback; bool m_SideEffectFree;