river/tags: fix memory leak of output_status_/seat_status_
The constructor created output_status_ and seat_status_ without adding any listener, then handle_show() recreated both (leaking the constructor-created objects) before destroying status_manager_. Additionally seat_status_ was never destroyed in ~Tags(). Create these objects lazily (with listeners) only in handle_show(), and destroy seat_status_ in the destructor.
This commit is contained in:
@@ -138,9 +138,10 @@ Tags::Tags(const std::string& id, const waybar::Bar& bar, const Json::Value& con
|
||||
return;
|
||||
}
|
||||
|
||||
// Store the output this module belongs to; the river_output_status and
|
||||
// river_seat_status objects (and their listeners) are created lazily in
|
||||
// handle_show() to avoid leaking objects without listeners here.
|
||||
output_ = gdk_wayland_monitor_get_wl_output(bar_.output->monitor->gobj());
|
||||
output_status_ = zriver_status_manager_v1_get_river_output_status(status_manager_, output_);
|
||||
seat_status_ = zriver_status_manager_v1_get_river_seat_status(status_manager_, seat_);
|
||||
|
||||
box_.set_name("tags");
|
||||
if (!id.empty()) {
|
||||
@@ -193,6 +194,10 @@ Tags::~Tags() {
|
||||
zriver_output_status_v1_destroy(output_status_);
|
||||
}
|
||||
|
||||
if (seat_status_) {
|
||||
zriver_seat_status_v1_destroy(seat_status_);
|
||||
}
|
||||
|
||||
if (control_) {
|
||||
zriver_control_v1_destroy(control_);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user