diff --git a/server/src/board/map/abstractsignalpath.cpp b/server/src/board/map/abstractsignalpath.cpp index db01b985..8c923f56 100644 --- a/server/src/board/map/abstractsignalpath.cpp +++ b/server/src/board/map/abstractsignalpath.cpp @@ -64,14 +64,6 @@ AbstractSignalPath::AbstractSignalPath(SignalRailTile& signal, size_t blocksAhea } } -AbstractSignalPath::~AbstractSignalPath() -{ - for(auto& connection : m_connections) - { - connection.disconnect(); - } -} - void AbstractSignalPath::evaluate() { const bool stop = !signal().hasReservedPath() && requireReservation(); diff --git a/server/src/board/map/abstractsignalpath.hpp b/server/src/board/map/abstractsignalpath.hpp index 855b4014..03c7651b 100644 --- a/server/src/board/map/abstractsignalpath.hpp +++ b/server/src/board/map/abstractsignalpath.hpp @@ -155,7 +155,7 @@ class AbstractSignalPath : public Path private: std::unique_ptr m_root; bool m_requireReservation = false; - std::vector m_connections; + std::vector m_connections; std::unique_ptr findBlocks(const Node& node, const Link& link, size_t blocksAhead); @@ -199,7 +199,7 @@ class AbstractSignalPath : public Path public: AbstractSignalPath(SignalRailTile& signal); AbstractSignalPath(SignalRailTile& signal, size_t blocksAhead); - virtual ~AbstractSignalPath(); + virtual ~AbstractSignalPath() = default; void evaluate(); }; diff --git a/server/src/core/objectlist.hpp b/server/src/core/objectlist.hpp index 18d39c77..da47b83b 100644 --- a/server/src/core/objectlist.hpp +++ b/server/src/core/objectlist.hpp @@ -42,7 +42,7 @@ class ObjectList : public AbstractObjectList protected: Items m_items; - std::unordered_map m_propertyChanged; + std::unordered_map m_propertyChanged; std::vector*> m_models; void deleteMethodHandler(const std::shared_ptr& object) @@ -121,12 +121,6 @@ class ObjectList : public AbstractObjectList static_assert(std::is_base_of_v); } - ~ObjectList() - { - for(auto& it : m_propertyChanged) - it.second.disconnect(); - } - inline const_iterator begin() const noexcept { return m_items.begin(); } inline const_iterator end() const noexcept { return m_items.end(); } inline const std::shared_ptr& front() const noexcept { return m_items.front(); } diff --git a/server/src/core/serialdeviceproperty.cpp b/server/src/core/serialdeviceproperty.cpp index 28b0766a..319bf27a 100644 --- a/server/src/core/serialdeviceproperty.cpp +++ b/server/src/core/serialdeviceproperty.cpp @@ -40,8 +40,3 @@ SerialDeviceProperty::SerialDeviceProperty(Object* object, std::string_view name static_cast&>(*it->second).internalChanged(); }); } - -SerialDeviceProperty::~SerialDeviceProperty() -{ - m_serialPortListChanged.disconnect(); -} diff --git a/server/src/core/serialdeviceproperty.hpp b/server/src/core/serialdeviceproperty.hpp index 5c0d10a0..a08b0a6c 100644 --- a/server/src/core/serialdeviceproperty.hpp +++ b/server/src/core/serialdeviceproperty.hpp @@ -29,11 +29,11 @@ class SerialDeviceProperty final : public Property { private: - boost::signals2::connection m_serialPortListChanged; + boost::signals2::scoped_connection m_serialPortListChanged; public: SerialDeviceProperty(Object* object, std::string_view name, const std::string& value, PropertyFlags flags); - ~SerialDeviceProperty() final; + ~SerialDeviceProperty() final = default; }; #endif diff --git a/server/src/hardware/interface/interfacelist.cpp b/server/src/hardware/interface/interfacelist.cpp index ca3718de..fe75e0d6 100644 --- a/server/src/hardware/interface/interfacelist.cpp +++ b/server/src/hardware/interface/interfacelist.cpp @@ -54,12 +54,6 @@ InterfaceList::InterfaceList(Object& _parent, std::string_view parentPropertyNam m_interfaceItems.add(delete_); } -InterfaceList::~InterfaceList() -{ - for(auto& it : m_statusPropertyChanged) - it.second.disconnect(); -} - TableModelPtr InterfaceList::getModel() { return std::make_shared(*this); diff --git a/server/src/hardware/interface/interfacelist.hpp b/server/src/hardware/interface/interfacelist.hpp index 73c46261..fd5c8caa 100644 --- a/server/src/hardware/interface/interfacelist.hpp +++ b/server/src/hardware/interface/interfacelist.hpp @@ -30,7 +30,7 @@ class InterfaceList final : public ObjectList { private: - std::unordered_map m_statusPropertyChanged; + std::unordered_map m_statusPropertyChanged; void statusPropertyChanged(BaseProperty& property); @@ -48,7 +48,7 @@ class InterfaceList final : public ObjectList Method&)> delete_; InterfaceList(Object& _parent, std::string_view parentPropertyName); - ~InterfaceList() final; + ~InterfaceList() final = default; TableModelPtr getModel() final; }; diff --git a/server/src/hardware/output/map/outputmap.cpp b/server/src/hardware/output/map/outputmap.cpp index b0378c9f..e05f2d2d 100644 --- a/server/src/hardware/output/map/outputmap.cpp +++ b/server/src/hardware/output/map/outputmap.cpp @@ -367,11 +367,7 @@ OutputMap::OutputMap(Object& _parent, std::string_view parentPropertyName) updateEnabled(); } -OutputMap::~OutputMap() -{ - m_interfaceDestroying.disconnect(); - m_outputECoSObjectsChanged.disconnect(); -} +OutputMap::~OutputMap() = default; void OutputMap::load(WorldLoader& loader, const nlohmann::json& data) { diff --git a/server/src/hardware/output/map/outputmap.hpp b/server/src/hardware/output/map/outputmap.hpp index 4ac1df2f..662cf1f3 100644 --- a/server/src/hardware/output/map/outputmap.hpp +++ b/server/src/hardware/output/map/outputmap.hpp @@ -50,8 +50,8 @@ class OutputMap : public SubObject static constexpr size_t addressesSizeMin = 1; static constexpr size_t addressesSizeMax = 8; - boost::signals2::connection m_interfaceDestroying; - boost::signals2::connection m_outputECoSObjectsChanged; + boost::signals2::scoped_connection m_interfaceDestroying; + boost::signals2::scoped_connection m_outputECoSObjectsChanged; void addOutput(OutputChannel ch, uint32_t id); void addOutput(OutputChannel ch, uint32_t id, OutputController& outputController); diff --git a/server/src/network/session.cpp b/server/src/network/session.cpp index 7f295114..fc9b5c86 100644 --- a/server/src/network/session.cpp +++ b/server/src/network/session.cpp @@ -55,9 +55,6 @@ Session::Session(const std::shared_ptr& connection) : Session::~Session() { assert(isEventLoopThread()); - m_memoryLoggerChanged.disconnect(); - for(const auto& it : m_objectSignals) - it.second.disconnect(); } bool Session::processMessage(const Message& message) diff --git a/server/src/network/session.hpp b/server/src/network/session.hpp index 7839ece5..25cdc865 100644 --- a/server/src/network/session.hpp +++ b/server/src/network/session.hpp @@ -58,7 +58,7 @@ class Session : public std::enable_shared_from_this static void writeAttribute(Message& message, const AbstractAttribute& attribute); static void writeTypeInfo(Message& message, const TypeInfo& typeInfo); - boost::signals2::connection m_memoryLoggerChanged; + boost::signals2::scoped_connection m_memoryLoggerChanged; protected: using Handle = uint32_t; @@ -67,7 +67,7 @@ class Session : public std::enable_shared_from_this std::shared_ptr m_connection; boost::uuids::uuid m_uuid; Handles m_handles; - std::unordered_multimap m_objectSignals; + std::unordered_multimap m_objectSignals; bool processMessage(const Message& message);