fix(amodule): prevent crash when cursor timeout fires after destruction

This commit is contained in:
Francois Lachese
2026-05-20 15:57:38 +02:00
parent 05945748dc
commit 876eaaf70f
2 changed files with 7 additions and 2 deletions
+6 -2
View File
@@ -17,7 +17,8 @@ AModule::AModule(const Json::Value& config, const std::string& name, const std::
isTooltip{config_["tooltip"].isBool() ? config_["tooltip"].asBool() : true},
isExpand{config_["expand"].isBool() ? config_["expand"].asBool() : false},
distance_scrolled_y_(0.0),
distance_scrolled_x_(0.0) {
distance_scrolled_x_(0.0),
cursor_timeout_conn_() {
// Configure module action Map
const Json::Value actions{config_["actions"]};
@@ -83,6 +84,9 @@ AModule::AModule(const Json::Value& config, const std::string& name, const std::
}
AModule::~AModule() {
if (cursor_timeout_conn_.connected()) {
cursor_timeout_conn_.disconnect();
}
for (const auto& pid : pid_children_) {
if (pid != -1) {
killpg(pid, SIGTERM);
@@ -118,7 +122,7 @@ void AModule::setCursor(Gdk::CursorType const& c) {
} else {
// window may not be accessible yet, in this case,
// schedule another call for setting the cursor in 1 sec
Glib::signal_timeout().connect_seconds(
cursor_timeout_conn_ = Glib::signal_timeout().connect_seconds(
[this, c]() {
setCursor(c);
return false;