Commit 280c51cc authored by Christian Hergert's avatar Christian Hergert
Browse files

style: various defensive cleanups

This does some cleanup to clear variables when we free them to
be less likely to have an invalid pointer use after free.
parent 838a1a4d
......@@ -607,17 +607,15 @@ gstyle_color_scale_finalize (GObject *object)
g_clear_object (&self->long_press_gesture);
g_clear_object (&self->default_provider);
g_sequence_free (self->custom_color_stops);
cairo_pattern_destroy (self->checkered_pattern);
if (self->pattern != NULL)
cairo_pattern_destroy (self->pattern);
g_clear_pointer (&self->custom_color_stops, g_sequence_free);
g_clear_pointer (&self->checkered_pattern, cairo_pattern_destroy);
g_clear_pointer (&self->pattern, cairo_pattern_destroy);
g_clear_pointer (&self->data_surface, cairo_pattern_destroy);
if (self->data_surface != NULL)
cairo_surface_destroy (self->data_surface);
g_clear_pointer (&self->data_raw, g_free);
g_clear_pointer (&self->data_raw_filtered, g_free);
g_free (self->data_raw);
g_free (self->data_raw_filtered);
}
static void
......
......@@ -1340,7 +1340,7 @@ gstyle_color_widget_finalize (GObject *object)
{
GstyleColorWidget *self = GSTYLE_COLOR_WIDGET (object);
if (self->color)
if (self->color != NULL)
gstyle_color_widget_disconnect_color (self);
g_clear_object (&self->multipress_gesture);
......@@ -1350,8 +1350,9 @@ gstyle_color_widget_finalize (GObject *object)
g_clear_object (&self->color);
g_clear_object (&self->filtered_color);
g_clear_object (&self->default_provider);
cairo_pattern_destroy (self->checkered_pattern);
gtk_target_list_unref (self->target_list);
g_clear_pointer (&self->checkered_pattern, cairo_pattern_destroy);
g_clear_pointer (&self->target_list, gtk_target_list_unref);
G_OBJECT_CLASS (gstyle_color_widget_parent_class)->finalize (object);
}
......
......@@ -102,14 +102,6 @@ gstyle_css_provider_new (void)
return g_object_new (GSTYLE_TYPE_CSS_PROVIDER, NULL);
}
static void
gstyle_css_provider_finalize (GObject *object)
{
/* GstyleCssProvider *self = (GstyleCssProvider *)object; */
G_OBJECT_CLASS (gstyle_css_provider_parent_class)->finalize (object);
}
static void
gstyle_css_provider_get_property (GObject *object,
guint prop_id,
......@@ -145,7 +137,6 @@ gstyle_css_provider_class_init (GstyleCssProviderClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
object_class->finalize = gstyle_css_provider_finalize;
object_class->get_property = gstyle_css_provider_get_property;
object_class->set_property = gstyle_css_provider_set_property;
}
......
......@@ -1105,12 +1105,11 @@ gstyle_palette_finalize (GObject *object)
{
GstylePalette *self = GSTYLE_PALETTE (object);
g_ptr_array_unref (self->colors);
g_hash_table_unref (self->color_names);
g_free (self->name);
g_free (self->id);
g_free (self->gettext_domain);
g_clear_pointer (&self->colors, g_ptr_array_unref);
g_clear_pointer (&self->color_names, g_hash_table_unref);
g_clear_pointer (&self->name, g_free);
g_clear_pointer (&self->id, g_free);
g_clear_pointer (&self->gettext_domain, g_free);
g_clear_object (&self->file);
G_OBJECT_CLASS (gstyle_palette_parent_class)->finalize (object);
......
......@@ -206,12 +206,6 @@ gstyle_rename_popover_new (void)
return g_object_new (GSTYLE_TYPE_RENAME_POPOVER, NULL);
}
static void
gstyle_rename_popover_finalize (GObject *object)
{
G_OBJECT_CLASS (gstyle_rename_popover_parent_class)->finalize (object);
}
static void
gstyle_rename_popover_get_property (GObject *object,
guint prop_id,
......@@ -272,7 +266,6 @@ gstyle_rename_popover_class_init (GstyleRenamePopoverClass *klass)
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->finalize = gstyle_rename_popover_finalize;
object_class->get_property = gstyle_rename_popover_get_property;
object_class->set_property = gstyle_rename_popover_set_property;
......
......@@ -221,12 +221,6 @@ gstyle_revealer_new (void)
return g_object_new (GSTYLE_TYPE_REVEALER, NULL);
}
static void
gstyle_revealer_finalize (GObject *object)
{
G_OBJECT_CLASS (gstyle_revealer_parent_class)->finalize (object);
}
static void
gstyle_revealer_get_preferred_width (GtkWidget *widget,
gint *min_width,
......@@ -316,12 +310,9 @@ gstyle_revealer_add (GtkContainer *container,
static void
gstyle_revealer_class_init (GstyleRevealerClass *klass)
{
GObjectClass *object_class = G_OBJECT_CLASS (klass);
GtkContainerClass *container_class = GTK_CONTAINER_CLASS (klass);
GtkWidgetClass *widget_class = GTK_WIDGET_CLASS (klass);
object_class->finalize = gstyle_revealer_finalize;
container_class->add = gstyle_revealer_add;
widget_class->size_allocate = gstyle_revealer_size_allocate;
......
......@@ -16,6 +16,8 @@
* along with this program. If not, see <http://www.gnu.org/licenses/>.
*/
#define G_LOG_DOMAIN "ide-debugger-frame"
#include "debugger/ide-debugger-frame.h"
typedef struct
......
......@@ -23,11 +23,12 @@
struct _IdeDocumentationInfo
{
GObject parent_instance;
GObject parent_instance;
gchar *input;
IdeDocumentationContext context;
GPtrArray *proposals;
IdeDocumentationContext context;
};
G_DEFINE_TYPE (IdeDocumentationInfo, ide_documentation_info, G_TYPE_OBJECT)
......
......@@ -25,8 +25,8 @@
struct _IdeDocumentation
{
GObject parent_instance;
PeasExtensionSet *extensions;
GObject parent_instance;
PeasExtensionSet *extensions;
};
G_DEFINE_TYPE (IdeDocumentation, ide_documentation, IDE_TYPE_OBJECT)
......
......@@ -48,7 +48,7 @@ ide_highlight_index_new (void)
{
IdeHighlightIndex *ret;
ret = g_new0 (IdeHighlightIndex, 1);
ret = g_slice_new0 (IdeHighlightIndex);
ret->ref_count = 1;
ret->strings = g_string_chunk_new (ide_get_system_page_size ());
ret->index = g_hash_table_new (g_str_hash, g_str_equal);
......@@ -117,9 +117,9 @@ ide_highlight_index_finalize (IdeHighlightIndex *self)
{
IDE_ENTRY;
g_string_chunk_free (self->strings);
g_hash_table_unref (self->index);
g_free (self);
g_clear_pointer (&self->strings, g_string_chunk_free);
g_clear_pointer (&self->index, g_hash_table_unref);
g_slice_free (IdeHighlightIndex, self);
DZL_COUNTER_DEC (instances);
......
......@@ -116,11 +116,13 @@ ide_layout_grid_column_remove (GtkContainer *container,
static void
ide_layout_grid_column_finalize (GObject *object)
{
#ifndef G_DISABLE_ASSERT
IdeLayoutGridColumn *self = (IdeLayoutGridColumn *)object;
g_assert (self->focus_stack.head == NULL);
g_assert (self->focus_stack.tail == NULL);
g_assert (self->focus_stack.length == 0);
#endif
G_OBJECT_CLASS (ide_layout_grid_column_parent_class)->finalize (object);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment