goptions: free opt types on exit from edit options view
Signed-off-by: Jens Axboe <axboe@kernel.dk>
diff --git a/goptions.c b/goptions.c
index f671dbe..ebb5c2d 100644
--- a/goptions.c
+++ b/goptions.c
@@ -95,7 +95,8 @@
/*
* Mark children as invisible, if needed.
*/
-static void gopt_set_children_visible(struct fio_option *parent, gboolean visible)
+static void gopt_set_children_visible(struct fio_option *parent,
+ gboolean visible)
{
struct fio_option *o;
int i;
@@ -137,7 +138,16 @@
gopt_widgets[idx] = gopt->box;
}
-static struct gopt *gopt_new_str_store(struct fio_option *o, const char *text, unsigned int idx)
+static void gopt_str_destroy(GtkWidget *w, gpointer data)
+{
+ struct gopt_str *s = (struct gopt_str *) data;
+
+ free(s);
+ gtk_widget_destroy(w);
+}
+
+static struct gopt *gopt_new_str_store(struct fio_option *o, const char *text,
+ unsigned int idx)
{
struct gopt_str *s;
GtkWidget *label;
@@ -157,6 +167,7 @@
gtk_entry_set_text(GTK_ENTRY(s->entry), text);
gtk_entry_set_editable(GTK_ENTRY(s->entry), 1);
s->gopt.sig_handler = g_signal_connect(GTK_OBJECT(s->entry), "changed", G_CALLBACK(gopt_str_changed), s);
+ g_signal_connect(GTK_OBJECT(s->entry), "destroy", G_CALLBACK(gopt_str_destroy), s);
if (o->def)
gtk_entry_set_text(GTK_ENTRY(s->entry), o->def);
@@ -175,7 +186,16 @@
printf("combo %s changed\n", o->name);
}
-static struct gopt_combo *__gopt_new_combo(struct fio_option *o, unsigned int idx)
+static void gopt_combo_destroy(GtkWidget *w, gpointer data)
+{
+ struct gopt_combo *c = (struct gopt_combo *) data;
+
+ free(c);
+ gtk_widget_destroy(w);
+}
+
+static struct gopt_combo *__gopt_new_combo(struct fio_option *o,
+ unsigned int idx)
{
struct gopt_combo *c;
GtkWidget *label;
@@ -192,6 +212,7 @@
c->combo = gtk_combo_box_new_text();
gopt_mark_index(&c->gopt, idx);
c->gopt.sig_handler = g_signal_connect(GTK_OBJECT(c->combo), "changed", G_CALLBACK(gopt_combo_changed), c);
+ g_signal_connect(GTK_OBJECT(c->combo), "destroy", G_CALLBACK(gopt_combo_destroy), c);
gtk_box_pack_start(GTK_BOX(c->gopt.box), c->combo, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(c->gopt.box), label, FALSE, FALSE, 0);
@@ -200,7 +221,8 @@
return c;
}
-static struct gopt *gopt_new_combo_str(struct fio_option *o, const char *text, unsigned int idx)
+static struct gopt *gopt_new_combo_str(struct fio_option *o, const char *text,
+ unsigned int idx)
{
struct gopt_combo *combo;
struct value_pair *vp;
@@ -224,7 +246,8 @@
return &combo->gopt;
}
-static struct gopt *gopt_new_combo_int(struct fio_option *o, unsigned int *ip, unsigned int idx)
+static struct gopt *gopt_new_combo_int(struct fio_option *o, unsigned int *ip,
+ unsigned int idx)
{
struct gopt_combo *combo;
struct value_pair *vp;
@@ -305,8 +328,16 @@
}
}
-static struct gopt_int *__gopt_new_int(struct fio_option *o, unsigned long long *p,
- unsigned int idx)
+static void gopt_int_destroy(GtkWidget *w, gpointer data)
+{
+ struct gopt_int *i = (struct gopt_int *) data;
+
+ free(i);
+ gtk_widget_destroy(w);
+}
+
+static struct gopt_int *__gopt_new_int(struct fio_option *o,
+ unsigned long long *p, unsigned int idx)
{
unsigned long long defval;
struct gopt_int *i;
@@ -345,6 +376,7 @@
gtk_spin_button_set_value(GTK_SPIN_BUTTON(i->spin), defval);
i->lastval = defval;
i->gopt.sig_handler = g_signal_connect(G_OBJECT(i->spin), "value-changed", G_CALLBACK(gopt_int_changed), i);
+ g_signal_connect(G_OBJECT(i->spin), "destroy", G_CALLBACK(gopt_int_destroy), i);
gtk_box_pack_start(GTK_BOX(i->gopt.box), i->spin, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(i->gopt.box), label, FALSE, FALSE, 0);
@@ -353,7 +385,8 @@
return i;
}
-static struct gopt *gopt_new_int(struct fio_option *o, unsigned int *ip, unsigned int idx)
+static struct gopt *gopt_new_int(struct fio_option *o, unsigned int *ip,
+ unsigned int idx)
{
unsigned long long ullp;
struct gopt_int *i;
@@ -397,7 +430,16 @@
gopt_set_children_visible(o, set);
}
-static struct gopt *gopt_new_bool(struct fio_option *o, unsigned int *val, unsigned int idx)
+static void gopt_bool_destroy(GtkWidget *w, gpointer data)
+{
+ struct gopt_bool *b = (struct gopt_bool *) data;
+
+ free(b);
+ gtk_widget_destroy(w);
+}
+
+static struct gopt *gopt_new_bool(struct fio_option *o, unsigned int *val,
+ unsigned int idx)
{
struct gopt_bool *b;
GtkWidget *label;
@@ -423,6 +465,7 @@
gtk_toggle_button_set_active(GTK_TOGGLE_BUTTON(b->check), defstate);
b->gopt.sig_handler = g_signal_connect(G_OBJECT(b->check), "toggled", G_CALLBACK(gopt_bool_toggled), b);
+ g_signal_connect(G_OBJECT(b->check), "destroy", G_CALLBACK(gopt_bool_destroy), b);
gtk_box_pack_start(GTK_BOX(b->gopt.box), b->check, FALSE, FALSE, 0);
gtk_box_pack_start(GTK_BOX(b->gopt.box), label, FALSE, FALSE, 0);
@@ -470,6 +513,14 @@
}
}
+static void gopt_range_destroy(GtkWidget *w, gpointer data)
+{
+ struct gopt_range *r = (struct gopt_range *) data;
+
+ free(r);
+ gtk_widget_destroy(w);
+}
+
static struct gopt *gopt_new_int_range(struct fio_option *o, unsigned int **ip,
unsigned int idx)
{
@@ -517,6 +568,7 @@
}
gtk_box_pack_start(GTK_BOX(r->gopt.box), label, FALSE, FALSE, 0);
+ g_signal_connect(G_OBJECT(r->gopt.box), "destroy", G_CALLBACK(gopt_range_destroy), r);
o->gui_data = r;
return &r->gopt;
}