Skip to content

Commit 22746a3

Browse files
yetistraveit65
authored andcommitted
Fix the runtime warning about gtk_widget_destroy.
1 parent 56c1867 commit 22746a3

1 file changed

Lines changed: 29 additions & 8 deletions

File tree

libslab/tile.c

Lines changed: 29 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,7 @@ typedef struct
3535
} TilePrivate;
3636

3737
static void tile_finalize (GObject *);
38+
static void tile_dispose (GObject *);
3839
static void tile_get_property (GObject *, guint, GValue *, GParamSpec *);
3940
static void tile_set_property (GObject *, guint, const GValue *, GParamSpec *);
4041
static GObject *tile_constructor (GType, guint, GObjectConstructParam *);
@@ -94,6 +95,7 @@ tile_class_init (TileClass * this_class)
9495
g_obj_class->get_property = tile_get_property;
9596
g_obj_class->set_property = tile_set_property;
9697
g_obj_class->finalize = tile_finalize;
98+
g_obj_class->dispose = tile_dispose;
9799

98100
widget_class->focus_in_event = tile_focus_in;
99101
widget_class->focus_out_event = tile_focus_out;
@@ -177,25 +179,44 @@ tile_finalize (GObject * g_object)
177179

178180
if (tile->n_actions) /* this will also free "default_action" entry */
179181
{
180-
gint x;
181-
for (x = 0; x < tile->n_actions; x++)
182-
{
183-
if (tile->actions[x])
184-
g_object_unref (tile->actions[x]);
185-
}
186182
g_free (tile->actions);
187183
}
188184

189185
if (tile->uri)
190186
g_free (tile->uri);
191-
if (tile->context_menu)
192-
gtk_widget_destroy (GTK_WIDGET (tile->context_menu));
193187

194188
g_object_unref (priv->double_click_detector);
195189

196190
(*G_OBJECT_CLASS (tile_parent_class)->finalize) (g_object);
197191
}
198192

193+
static void
194+
tile_dispose (GObject * g_object)
195+
{
196+
Tile *tile = TILE (g_object);
197+
198+
/* free the TileAction object */
199+
if (tile->n_actions)
200+
{
201+
gint x;
202+
for (x = 0; x < tile->n_actions; x++)
203+
{
204+
if (tile->actions[x] != NULL) {
205+
g_object_unref (tile->actions[x]);
206+
tile->actions[x] = NULL;
207+
}
208+
}
209+
}
210+
211+
/* free the GtkMenu object */
212+
if (tile->context_menu != NULL) {
213+
gtk_widget_destroy (GTK_WIDGET (tile->context_menu));
214+
tile->context_menu = NULL;
215+
}
216+
217+
(*G_OBJECT_CLASS (tile_parent_class)->dispose) (g_object);
218+
}
219+
199220
static void
200221
tile_get_property (GObject * g_obj, guint prop_id, GValue * value, GParamSpec * param_spec)
201222
{

0 commit comments

Comments
 (0)