gplugin/gplugin

Fix a leak in settings list

14 months ago, Elliott Sales de Andrade
2695cbb5e004
Fix a leak in settings list

Fixes a leak for plugins that have settings:
```
48 (32 direct, 16 indirect) bytes in 1 blocks are definitely lost in loss record 12,560 of 29,780
at 0x4A231EF: g_type_create_instance (gtype.c:1909)
by 0x4A08C1F: g_object_new_internal (gobject.c:2228)
by 0x4A0A247: g_object_new_with_properties (gobject.c:2391)
by 0x4A0AFF0: g_object_new (gobject.c:2037)
by 0x4C64DA7: gtk_size_group_new (gtksizegroup.c:300)
by 0x487356A: gplugin_gtk_plugin_settings_list_refresh (gplugin-gtk-plugin-settings-list.c:492)
by 0x4873CBA: gplugin_gtk_plugin_settings_list_set_settings (gplugin-gtk-plugin-settings-list.c:662)
by 0x4870DEE: gplugin_gtk_plugin_page_update_settings_list (gplugin-gtk-plugin-page.c:98)
by 0x48717DD: gplugin_gtk_plugin_page_set_plugin (gplugin-gtk-plugin-page.c:394)
by 0x48750EF: gplugin_gtk_view_show_plugin (gplugin-gtk-view.c:567)
by 0x4873FD0: gplugin_gtk_view_row_activated (gplugin-gtk-view.c:82)
by 0x49F8A64: g_cclosure_marshal_VOID__OBJECTv (gmarshal.c:1910)
```

Testing Done:
Opened viewer in valgrind, went to settings plugin's info, and leak was no longer there.

Reviewed at https://reviews.imfreedom.org/r/2305/
/*
* Copyright 2021 Elliott Sales de Andrade <quantum.analyst@gmail.com>
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#include <gplugin-gtk.h>
#include "gplugin-gtk-viewer-window.h"
struct _GPluginGtkViewerWindow {
GtkApplicationWindow parent;
GPluginGtkView *view;
};
G_DEFINE_TYPE(
GPluginGtkViewerWindow,
gplugin_gtk_viewer_window,
GTK_TYPE_APPLICATION_WINDOW)
/******************************************************************************
* GObject Stuff
*****************************************************************************/
static void
gplugin_gtk_viewer_window_class_init(GPluginGtkViewerWindowClass *klass)
{
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS(klass);
gtk_widget_class_set_template_from_resource(
widget_class,
"/org/imfreedom/keep/gplugin/gplugin/viewer/window.ui");
gtk_widget_class_bind_template_child(
widget_class,
GPluginGtkViewerWindow,
view);
gtk_widget_class_add_binding_action(
widget_class,
GDK_KEY_w,
GDK_CONTROL_MASK,
"window.close",
NULL);
}
static void
gplugin_gtk_viewer_window_init(GPluginGtkViewerWindow *self)
{
gtk_widget_init_template(GTK_WIDGET(self));
}
/******************************************************************************
* Public API
*****************************************************************************/
GPluginGtkView *
gplugin_gtk_viewer_window_get_view(GPluginGtkViewerWindow *window)
{
return window->view;
}