Skip to content

Commit 75a067c

Browse files
Issue 3981: try and fix memory leak
1 parent 0332d2e commit 75a067c

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/modules/privacy/privacy_item.cpp

+5-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#include "modules/privacy/privacy_item.hpp"
22

33
#include <string>
4+
#include <spdlog/spdlog.h>
45

56
#include "glibmm/main.h"
67
#include "gtkmm/label.h"
@@ -94,22 +95,22 @@ PrivacyItem::PrivacyItem(const Json::Value &config_, enum PrivacyNodeType privac
9495
}
9596

9697
void PrivacyItem::update_tooltip() {
98+
spdlog::trace("update privacy tooltip");
9799
// Removes all old nodes
98100
for (auto *child : tooltip_window.get_children()) {
99-
delete child;
101+
tooltip_window.remove(*child);
100102
}
101-
102103
for (auto *node : *nodes) {
103104
Gtk::Box *box = new Gtk::Box(Gtk::ORIENTATION_HORIZONTAL, 4);
104105

105106
// Set device icon
106-
Gtk::Image *node_icon = new Gtk::Image();
107+
Gtk::Image *node_icon = Gtk::make_managed<Gtk::Image>();
107108
node_icon->set_pixel_size(tooltipIconSize);
108109
node_icon->set_from_icon_name(node->getIconName(), Gtk::ICON_SIZE_INVALID);
109110
box->add(*node_icon);
110111

111112
// Set model
112-
auto *nodeName = new Gtk::Label(node->getName());
113+
auto *nodeName = Gtk::make_managed<Gtk::Label>(node->getName());
113114
box->add(*nodeName);
114115

115116
tooltip_window.add(*box);

0 commit comments

Comments
 (0)