mirror of
https://github.com/rad4day/Waybar.git
synced 2023-12-21 10:22:59 +01:00
bar: Fix crash when unplugging HDMI
There is a double delete situation which causes a SIGSEGV to happen during destruction of bar. This was introduced by the group feature patch. The same object pointer is stored in two different vectors of unique_ptr<AModule> element. Replace with shared_ptr to handle reference counting correctly and avoid double delete.
This commit is contained in:
@ -735,18 +735,19 @@ void waybar::Bar::getModules(const Factory& factory, const std::string& pos, Gtk
|
||||
module = factory.makeModule(ref);
|
||||
}
|
||||
|
||||
modules_all_.emplace_back(module);
|
||||
std::shared_ptr<AModule> module_sp(module);
|
||||
modules_all_.emplace_back(module_sp);
|
||||
if (group) {
|
||||
group->pack_start(*module, false, false);
|
||||
} else {
|
||||
if (pos == "modules-left") {
|
||||
modules_left_.emplace_back(module);
|
||||
modules_left_.emplace_back(module_sp);
|
||||
}
|
||||
if (pos == "modules-center") {
|
||||
modules_center_.emplace_back(module);
|
||||
modules_center_.emplace_back(module_sp);
|
||||
}
|
||||
if (pos == "modules-right") {
|
||||
modules_right_.emplace_back(module);
|
||||
modules_right_.emplace_back(module_sp);
|
||||
}
|
||||
}
|
||||
module->dp.connect([module, &name] {
|
||||
|
Reference in New Issue
Block a user