mirror of
https://github.com/rad4day/Waybar.git
synced 2025-07-14 23:22:31 +02:00
Revert "Fix potential memory leaks"
This commit is contained in:
@ -63,7 +63,7 @@ UPower::UPower(const std::string& id, const Json::Value& config)
|
||||
box_.set_has_tooltip(tooltip_enabled);
|
||||
if (tooltip_enabled) {
|
||||
// Sets the window to use when showing the tooltip
|
||||
upower_tooltip = std::make_unique<UPowerTooltip>(iconSize, tooltip_spacing, tooltip_padding);
|
||||
upower_tooltip = new UPowerTooltip(iconSize, tooltip_spacing, tooltip_padding);
|
||||
box_.set_tooltip_window(*upower_tooltip);
|
||||
box_.signal_query_tooltip().connect(sigc::mem_fun(*this, &UPower::show_tooltip_callback));
|
||||
}
|
||||
@ -72,13 +72,14 @@ UPower::UPower(const std::string& id, const Json::Value& config)
|
||||
G_BUS_NAME_WATCHER_FLAGS_AUTO_START, upowerAppear,
|
||||
upowerDisappear, this, NULL);
|
||||
|
||||
client = up_client_new_full(NULL, NULL);
|
||||
GError* error = NULL;
|
||||
client = up_client_new_full(NULL, &error);
|
||||
if (client == NULL) {
|
||||
throw std::runtime_error("Unable to create UPower client!");
|
||||
}
|
||||
|
||||
// Connect to Login1 PrepareForSleep signal
|
||||
login1_connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, NULL);
|
||||
login1_connection = g_bus_get_sync(G_BUS_TYPE_SYSTEM, NULL, &error);
|
||||
if (!login1_connection) {
|
||||
throw std::runtime_error("Unable to connect to the SYSTEM Bus!...");
|
||||
} else {
|
||||
@ -98,7 +99,6 @@ UPower::UPower(const std::string& id, const Json::Value& config)
|
||||
}
|
||||
|
||||
UPower::~UPower() {
|
||||
if (displayDevice != NULL) g_object_unref(displayDevice);
|
||||
if (client != NULL) g_object_unref(client);
|
||||
if (login1_id > 0) {
|
||||
g_dbus_connection_signal_unsubscribe(login1_connection, login1_id);
|
||||
|
@ -9,10 +9,11 @@
|
||||
namespace waybar::modules::upower {
|
||||
UPowerTooltip::UPowerTooltip(uint iconSize_, uint tooltipSpacing_, uint tooltipPadding_)
|
||||
: Gtk::Window(),
|
||||
contentBox(std::make_unique<Gtk::Box>(Gtk::ORIENTATION_VERTICAL)),
|
||||
iconSize(iconSize_),
|
||||
tooltipSpacing(tooltipSpacing_),
|
||||
tooltipPadding(tooltipPadding_) {
|
||||
contentBox = new Gtk::Box(Gtk::ORIENTATION_VERTICAL);
|
||||
|
||||
// Sets the Tooltip Padding
|
||||
contentBox->set_margin_top(tooltipPadding);
|
||||
contentBox->set_margin_bottom(tooltipPadding);
|
||||
|
Reference in New Issue
Block a user