diff --git a/include/modules/privacy/privacy.hpp b/include/modules/privacy/privacy.hpp index 7307afc9..41145e50 100644 --- a/include/modules/privacy/privacy.hpp +++ b/include/modules/privacy/privacy.hpp @@ -17,6 +17,7 @@ namespace waybar::modules::privacy { class Privacy : public AModule { public: Privacy(const std::string&, const Json::Value&, Gtk::Orientation, const std::string& pos); + ~Privacy() override; auto update() -> void override; private: diff --git a/src/modules/privacy/privacy.cpp b/src/modules/privacy/privacy.cpp index 7bb9de92..76762cf5 100644 --- a/src/modules/privacy/privacy.cpp +++ b/src/modules/privacy/privacy.cpp @@ -119,6 +119,15 @@ Privacy::Privacy(const std::string& id, const Json::Value& config, Gtk::Orientat sigc::mem_fun(*this, &Privacy::onGeoCluePrivacyNodesChanged)); } +Privacy::~Privacy() { + // Both timeouts are attached to the global main context, which outlives this + // module when the bar is reloaded. sigc::connection's destructor does not + // disconnect, and the members are torn down after the backends they use, so a + // pending timeout would dispatch onto freed memory. + geoclue_timeout_conn.disconnect(); + visibility_conn.disconnect(); +} + void Privacy::onPWPrivacyNodesChanged() { mutex_.lock(); nodes_audio_out.clear();