Skip to content

Commit

Permalink
modules/upower: use smart pointer to avoid memory leak
Browse files Browse the repository at this point in the history
  • Loading branch information
taminob committed Oct 21, 2023
1 parent 8c57756 commit a73669b
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
3 changes: 2 additions & 1 deletion include/modules/upower/upower_tooltip.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@

#include <libupower-glib/upower.h>

#include <memory>
#include <unordered_map>

#include "gtkmm/box.h"
Expand All @@ -16,7 +17,7 @@ class UPowerTooltip : public Gtk::Window {

const std::string getDeviceIcon(UpDeviceKind& kind);

Gtk::Box* contentBox;
std::unique_ptr<Gtk::Box> contentBox;

uint iconSize;
uint tooltipSpacing;
Expand Down
3 changes: 1 addition & 2 deletions src/modules/upower/upower_tooltip.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,10 @@
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);
Expand Down

0 comments on commit a73669b

Please sign in to comment.