fix(hyprland/workspaces): disconnect hover-check timeout on Workspace destruction
The hover-check Glib::signal_timeout re-arms every 50ms and is not owned by the Workspace. Since Workspaces are destroyed at runtime, a workspace removed while its check is armed would let the timeout fire on freed memory (use-after- free, also touching the destroyed m_button). Add a destructor that calls stopHoverCheck() to disconnect the source.
This commit is contained in:
@@ -30,6 +30,7 @@ class Workspace {
|
|||||||
public:
|
public:
|
||||||
explicit Workspace(const Json::Value& workspace_data, Workspaces& workspace_manager,
|
explicit Workspace(const Json::Value& workspace_data, Workspaces& workspace_manager,
|
||||||
const Json::Value& clients_data = Json::Value::nullRef);
|
const Json::Value& clients_data = Json::Value::nullRef);
|
||||||
|
~Workspace();
|
||||||
std::string& selectIcon(std::map<std::string, std::string>& icons_map);
|
std::string& selectIcon(std::map<std::string, std::string>& icons_map);
|
||||||
Gtk::Button& button() { return m_button; };
|
Gtk::Button& button() { return m_button; };
|
||||||
|
|
||||||
|
|||||||
@@ -51,6 +51,12 @@ Workspace::Workspace(const Json::Value& workspace_data, Workspaces& workspace_ma
|
|||||||
initializeWindowMap(clients_data);
|
initializeWindowMap(clients_data);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Workspace::~Workspace() {
|
||||||
|
// Disconnect the hover-check timeout so it can't fire on this destroyed
|
||||||
|
// instance (Workspaces are removed at runtime while a check may be armed).
|
||||||
|
stopHoverCheck();
|
||||||
|
}
|
||||||
|
|
||||||
void addOrRemoveClass(const Glib::RefPtr<Gtk::StyleContext>& context, bool condition,
|
void addOrRemoveClass(const Glib::RefPtr<Gtk::StyleContext>& context, bool condition,
|
||||||
const std::string& class_name) {
|
const std::string& class_name) {
|
||||||
if (condition) {
|
if (condition) {
|
||||||
|
|||||||
Reference in New Issue
Block a user