diff --git a/src/network_manager.cpp b/src/network_manager.cpp index 47a528f08..5206e366f 100644 --- a/src/network_manager.cpp +++ b/src/network_manager.cpp @@ -75,8 +75,8 @@ Manager::Manager(stdplus::PinnedRef bus, } }) { - reload.get().setCallback([&]() { - for (auto& hook : reloadPreHooks) + reload.get().setCallback([self = stdplus::PinnedRef(*this)]() { + for (auto& hook : self.get().reloadPreHooks) { try { @@ -88,10 +88,11 @@ Manager::Manager(stdplus::PinnedRef bus, "ERROR", ex); } } - reloadPreHooks.clear(); + self.get().reloadPreHooks.clear(); try { - bus.get() + self.get() + .bus.get() .new_method_call("org.freedesktop.network1", "/org/freedesktop/network1", "org.freedesktop.network1.Manager", "Reload") @@ -101,9 +102,9 @@ Manager::Manager(stdplus::PinnedRef bus, catch (const sdbusplus::exception_t& ex) { lg2::error("Failed to reload configuration: {ERROR}", "ERROR", ex); - reloadPostHooks.clear(); + self.get().reloadPostHooks.clear(); } - for (auto& hook : reloadPostHooks) + for (auto& hook : self.get().reloadPostHooks) { try { @@ -115,7 +116,7 @@ Manager::Manager(stdplus::PinnedRef bus, "ERROR", ex); } } - reloadPostHooks.clear(); + self.get().reloadPostHooks.clear(); }); std::vector< std::tuple>