[gnome-software: 89/110] Properly unparent children of custom widgets
- From: Philip Withnall <pwithnall src gnome org>
- To: commits-list gnome org
- Cc:
- Subject: [gnome-software: 89/110] Properly unparent children of custom widgets
- Date: Tue, 5 Oct 2021 20:32:42 +0000 (UTC)
commit ab6f087f823efeff25fc52dd3132eced6f73918c
Author: Georges Basile Stavracas Neto <georges stavracas gmail com>
Date: Thu Aug 26 14:55:13 2021 -0300
Properly unparent children of custom widgets
We need to unparent them on dispose.
src/gs-info-bar.c | 10 ++++++++++
src/gs-license-tile.c | 1 +
src/gs-page.c | 2 ++
src/gs-review-histogram.c | 12 ++++++++++++
src/gs-screenshot-carousel.c | 2 ++
src/gs-screenshot-image.c | 1 +
src/gs-star-widget.c | 10 ++++++++++
7 files changed, 38 insertions(+)
---
diff --git a/src/gs-info-bar.c b/src/gs-info-bar.c
index fc946f80f..e25e5d5c2 100644
--- a/src/gs-info-bar.c
+++ b/src/gs-info-bar.c
@@ -8,6 +8,7 @@
#include "config.h"
+#include "gs-common.h"
#include "gs-info-bar.h"
struct _GsInfoBar
@@ -84,6 +85,14 @@ gs_info_bar_set_property (GObject *object,
}
}
+static void
+gs_info_bar_dispose (GObject *object)
+{
+ gs_widget_remove_all (GTK_WIDGET (object), NULL);
+
+ G_OBJECT_CLASS (gs_info_bar_parent_class)->dispose (object);
+}
+
static void
gs_info_bar_init (GsInfoBar *infobar)
{
@@ -98,6 +107,7 @@ gs_info_bar_class_init (GsInfoBarClass *klass)
object_class->get_property = gs_info_bar_get_property;
object_class->set_property = gs_info_bar_set_property;
+ object_class->dispose = gs_info_bar_dispose;
g_object_class_install_property (object_class, PROP_TITLE,
g_param_spec_string ("title",
diff --git a/src/gs-license-tile.c b/src/gs-license-tile.c
index 30a65fb94..ed34793cd 100644
--- a/src/gs-license-tile.c
+++ b/src/gs-license-tile.c
@@ -180,6 +180,7 @@ gs_license_tile_dispose (GObject *object)
GsLicenseTile *self = GS_LICENSE_TILE (object);
gs_license_tile_set_app (self, NULL);
+ gs_widget_remove_all (GTK_WIDGET (self), NULL);
G_OBJECT_CLASS (gs_license_tile_parent_class)->dispose (object);
}
diff --git a/src/gs-page.c b/src/gs-page.c
index 563d1c8fb..91d1c0b8d 100644
--- a/src/gs-page.c
+++ b/src/gs-page.c
@@ -815,6 +815,8 @@ gs_page_dispose (GObject *object)
GsPage *page = GS_PAGE (object);
GsPagePrivate *priv = gs_page_get_instance_private (page);
+ gs_widget_remove_all (GTK_WIDGET (page), NULL);
+
g_clear_object (&priv->plugin_loader);
g_clear_object (&priv->header_start_widget);
g_clear_object (&priv->header_end_widget);
diff --git a/src/gs-review-histogram.c b/src/gs-review-histogram.c
index 173dd2990..cbd27b5a2 100644
--- a/src/gs-review-histogram.c
+++ b/src/gs-review-histogram.c
@@ -10,6 +10,7 @@
#include <math.h>
+#include "gs-common.h"
#include "gs-review-histogram.h"
#include "gs-review-bar.h"
#include "gs-star-image.h"
@@ -87,6 +88,14 @@ gs_review_histogram_set_ratings (GsReviewHistogram *histogram,
gs_star_image_set_fraction (GS_STAR_IMAGE (priv->star_value_5), CLAMP (fraction[0], 4.0, 5.0) - 4.0);
}
+static void
+gs_review_histogram_dispose (GObject *object)
+{
+ gs_widget_remove_all (GTK_WIDGET (object), NULL);
+
+ G_OBJECT_CLASS (gs_review_histogram_parent_class)->dispose (object);
+}
+
static void
gs_review_histogram_init (GsReviewHistogram *histogram)
{
@@ -96,8 +105,11 @@ gs_review_histogram_init (GsReviewHistogram *histogram)
static void
gs_review_histogram_class_init (GsReviewHistogramClass *klass)
{
+ GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ object_class->dispose = gs_review_histogram_dispose;
+
gtk_widget_class_set_template_from_resource (widget_class,
"/org/gnome/Software/gs-review-histogram.ui");
gtk_widget_class_set_layout_manager_type (widget_class, GTK_TYPE_BIN_LAYOUT);
diff --git a/src/gs-screenshot-carousel.c b/src/gs-screenshot-carousel.c
index c54f4379e..95b1de166 100644
--- a/src/gs-screenshot-carousel.c
+++ b/src/gs-screenshot-carousel.c
@@ -297,6 +297,8 @@ gs_screenshot_carousel_dispose (GObject *object)
{
GsScreenshotCarousel *self = GS_SCREENSHOT_CAROUSEL (object);
+ gs_widget_remove_all (GTK_WIDGET (self), NULL);
+
g_clear_object (&self->session);
G_OBJECT_CLASS (gs_screenshot_carousel_parent_class)->dispose (object);
diff --git a/src/gs-screenshot-image.c b/src/gs-screenshot-image.c
index b8eca0220..374e57171 100644
--- a/src/gs-screenshot-image.c
+++ b/src/gs-screenshot-image.c
@@ -666,6 +666,7 @@ gs_screenshot_image_dispose (GObject *object)
SOUP_STATUS_CANCELLED);
g_clear_object (&ssimg->message);
}
+ gs_widget_remove_all (GTK_WIDGET (ssimg), NULL);
g_clear_object (&ssimg->screenshot);
g_clear_object (&ssimg->session);
g_clear_object (&ssimg->settings);
diff --git a/src/gs-star-widget.c b/src/gs-star-widget.c
index ef3193878..ab91a6302 100644
--- a/src/gs-star-widget.c
+++ b/src/gs-star-widget.c
@@ -242,6 +242,14 @@ gs_star_widget_realize (GtkWidget *widget)
gs_star_widget_refresh (GS_STAR_WIDGET (widget));
}
+static void
+gs_star_widget_dispose (GObject *object)
+{
+ gs_widget_remove_all (GTK_WIDGET (object), NULL);
+
+ G_OBJECT_CLASS (gs_star_widget_parent_class)->dispose (object);
+}
+
static void
gs_star_widget_init (GsStarWidget *star)
{
@@ -254,6 +262,8 @@ gs_star_widget_class_init (GsStarWidgetClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
+ object_class->dispose = gs_star_widget_dispose;
+
widget_class->realize = gs_star_widget_realize;
object_class->get_property = gs_star_widget_get_property;
object_class->set_property = gs_star_widget_set_property;
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]