diff --git a/src/lib/dbus/ObjectManager.hxx b/src/lib/dbus/ObjectManager.hxx index 5a8cbf9d5..e37ee28e8 100644 --- a/src/lib/dbus/ObjectManager.hxx +++ b/src/lib/dbus/ObjectManager.hxx @@ -70,8 +70,8 @@ template inline void ForEachInterface(ReadMessageIter &&i, F &&f) { - i.ForEach(DBUS_TYPE_DICT_ENTRY, [&f](auto &&j){ - RecurseInterfaceDictEntry(j.Recurse(), f); + i.ForEachRecurse(DBUS_TYPE_DICT_ENTRY, [&f](auto &&j){ + RecurseInterfaceDictEntry(std::move(j), f); }); } diff --git a/src/lib/dbus/ReadIter.hxx b/src/lib/dbus/ReadIter.hxx index d51dd371c..60312a33c 100644 --- a/src/lib/dbus/ReadIter.hxx +++ b/src/lib/dbus/ReadIter.hxx @@ -91,6 +91,17 @@ public: for (; GetArgType() == arg_type; Next()) f(*this); } + + /** + * Wrapper for ForEach() which passes a recursed iterator for + * each element. + */ + template + void ForEachRecurse(int arg_type, F &&f) { + ForEach(arg_type, [&f](auto &&i){ + f(i.Recurse()); + }); + } }; } /* namespace ODBus */