summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--gtk/src/callbacks.c2
-rw-r--r--gtk/src/hb-backend.c10
-rw-r--r--gtk/src/hb-backend.h1
-rw-r--r--gtk/src/main.c10
-rw-r--r--gtk/src/plist.c2
-rw-r--r--gtk/src/presets.c11
-rw-r--r--gtk/src/presets.h1
-rw-r--r--gtk/src/settings.c6
-rw-r--r--gtk/src/values.c56
9 files changed, 75 insertions, 24 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c
index 453fa693a..c8c54175a 100644
--- a/gtk/src/callbacks.c
+++ b/gtk/src/callbacks.c
@@ -2091,8 +2091,10 @@ ghb_select_preset(GtkBuilder *builder, const gchar *preset)
{
gtk_tree_selection_select_iter (selection, &iter);
foundit = TRUE;
+ g_free(tpreset);
break;
}
+ g_free(tpreset);
done = !gtk_tree_model_iter_next(store, &iter);
} while (!done);
}
diff --git a/gtk/src/hb-backend.c b/gtk/src/hb-backend.c
index 44ca2346d..d9f4cdbc5 100644
--- a/gtk/src/hb-backend.c
+++ b/gtk/src/hb-backend.c
@@ -400,6 +400,7 @@ del_tree(const gchar *name, gboolean del_top)
}
if (del_top)
g_rmdir(name);
+ g_dir_close(gdir);
}
else
{
@@ -1226,6 +1227,7 @@ title_opts_set(GtkBuilder *builder, const gchar *name)
3, ii,
4, option,
-1);
+ g_free(option);
}
}
@@ -1270,6 +1272,7 @@ audio_rate_opts_add(GtkBuilder *builder, const gchar *name, gint rate)
3, rate,
4, str,
-1);
+ g_free(str);
return TRUE;
}
return FALSE;
@@ -1689,6 +1692,13 @@ ghb_backend_init(GtkBuilder *builder, gint debug, gint update)
}
void
+ghb_backend_close()
+{
+ hb_close(&h_queue);
+ hb_close(&h_scan);
+}
+
+void
ghb_backend_scan(const gchar *path, gint titleindex)
{
hb_scan( h_scan, path, titleindex );
diff --git a/gtk/src/hb-backend.h b/gtk/src/hb-backend.h
index 2d04a0090..0972e1b10 100644
--- a/gtk/src/hb-backend.h
+++ b/gtk/src/hb-backend.h
@@ -83,6 +83,7 @@ const gchar* ghb_version(void);
void ghb_vquality_range(signal_user_data_t *ud, gint *min, gint *max);
//const gchar* ghb_get_rate_string(gint rate, gint type);
void ghb_backend_init(GtkBuilder *builder, gint debug, gint update);
+void ghb_backend_close(void);
void ghb_add_job(GValue *js, gint unique_id);
void ghb_remove_job(gint unique_id);
void ghb_start_queue(void);
diff --git a/gtk/src/main.c b/gtk/src/main.c
index 02012b9bd..40307c8eb 100644
--- a/gtk/src/main.c
+++ b/gtk/src/main.c
@@ -39,6 +39,7 @@
#include "hb-backend.h"
#include "ghb-dvd.h"
#include "ghbcellrenderertext.h"
+#include "values.h"
/*
@@ -492,6 +493,7 @@ main (int argc, char *argv[])
g_option_context_add_main_entries (context, entries, GETTEXT_PACKAGE);
g_option_context_add_group (context, gtk_get_option_group (TRUE));
g_option_context_parse (context, &argc, &argv, &error);
+ g_option_context_free(context);
gtk_set_locale ();
gtk_init (&argc, &argv);
@@ -612,6 +614,14 @@ main (int argc, char *argv[])
g_timeout_add (500, ghb_timer_cb, (gpointer)ud);
// Everything should be go-to-go. Lets rock!
gtk_main ();
+ //I'd like to do this, but hb threads seem to persist for a while
+ //so closing crashes :\
+ //ghb_backend_close();
+ if (ud->queue)
+ ghb_value_free(ud->queue);
+ ghb_value_free(ud->settings);
+ g_io_channel_unref(ud->activity_log);
+ ghb_settings_close();
g_free(ud);
return 0;
}
diff --git a/gtk/src/plist.c b/gtk/src/plist.c
index b0a39c31b..d3dcf2af0 100644
--- a/gtk/src/plist.c
+++ b/gtk/src/plist.c
@@ -250,7 +250,7 @@ end_element(
} break;
case P_STRING:
{
- gval = ghb_string_value_new(g_strdup(pd->value));
+ gval = ghb_string_value_new(pd->value);
} break;
case P_DATE:
{
diff --git a/gtk/src/presets.c b/gtk/src/presets.c
index 9052e1ec7..e2b0eb216 100644
--- a/gtk/src/presets.c
+++ b/gtk/src/presets.c
@@ -594,6 +594,17 @@ ghb_settings_init(signal_user_data_t *ud)
}
void
+ghb_settings_close()
+{
+ if (internalPlist)
+ ghb_value_free(internalPlist);
+ if (presetsPlist)
+ ghb_value_free(presetsPlist);
+ if (prefsPlist)
+ ghb_value_free(prefsPlist);
+}
+
+void
ghb_prefs_load(signal_user_data_t *ud)
{
GValue *dict, *internal;
diff --git a/gtk/src/presets.h b/gtk/src/presets.h
index b216c5580..c8fbc5044 100644
--- a/gtk/src/presets.h
+++ b/gtk/src/presets.h
@@ -29,6 +29,7 @@ void ghb_update_from_preset(
void ghb_presets_remove(const gchar *name);
void ghb_prefs_load(signal_user_data_t *ud);
void ghb_settings_init(signal_user_data_t *ud);
+void ghb_settings_close();
void ghb_prefs_to_ui(signal_user_data_t *ud);
void ghb_prefs_save(GValue *settings);
void ghb_pref_save(GValue *settings, const gchar *key);
diff --git a/gtk/src/settings.c b/gtk/src/settings.c
index 1fad691ce..d7b824bbb 100644
--- a/gtk/src/settings.c
+++ b/gtk/src/settings.c
@@ -285,6 +285,9 @@ ghb_widget_value(GtkWidget *widget)
3, &ivalue, 4, &svalue, -1);
value = ghb_combo_value_new(index, option, shortOpt,
svalue, ivalue);
+ g_free(option);
+ g_free(shortOpt);
+ g_free(svalue);
}
else
{
@@ -413,7 +416,10 @@ ghb_widget_index(GtkWidget *widget)
if (value == NULL) return 0;
ghb_combodata_t *cd;
if (G_VALUE_TYPE(value) != ghb_combodata_get_type())
+ {
+ ghb_value_free(value);
return 0;
+ }
cd = g_value_get_boxed(value);
index = cd->index;
ghb_value_free(value);
diff --git a/gtk/src/values.c b/gtk/src/values.c
index b6be28af4..0f6c43285 100644
--- a/gtk/src/values.c
+++ b/gtk/src/values.c
@@ -48,101 +48,111 @@ ghb_value_dup(const GValue *val)
gint
ghb_value_int(const GValue *val)
{
+ gint result;
+
if (val == NULL) return 0;
- const GValue *gval;
GValue xform = {0,};
if (G_VALUE_TYPE(val) != G_TYPE_INT64)
{
g_value_init(&xform, G_TYPE_INT64);
if (!g_value_transform(val, &xform))
return 0;
- gval = &xform;
+ result = (gint)g_value_get_int64(&xform);
+ g_value_unset(&xform);
}
else
{
- gval = val;
+ result = (gint)g_value_get_int64(val);
}
- return (gint)g_value_get_int64(gval);
+ return result;
}
gint64
ghb_value_int64(const GValue *val)
{
+ gint64 result;
+
if (val == NULL) return 0;
- const GValue *gval;
GValue xform = {0,};
if (G_VALUE_TYPE(val) != G_TYPE_INT64)
{
g_value_init(&xform, G_TYPE_INT64);
if (!g_value_transform(val, &xform))
return 0;
- gval = &xform;
+ result = g_value_get_int64(&xform);
+ g_value_unset(&xform);
}
else
{
- gval = val;
+ result = g_value_get_int64(val);
}
- return g_value_get_int64(gval);
+ return result;
}
gdouble
ghb_value_double(const GValue *val)
{
+ gdouble result;
+
if (val == NULL) return 0;
- const GValue *gval;
GValue xform = {0,};
if (G_VALUE_TYPE(val) != G_TYPE_DOUBLE)
{
g_value_init(&xform, G_TYPE_DOUBLE);
if (!g_value_transform(val, &xform))
return 0;
- gval = &xform;
+ result = g_value_get_double(&xform);
+ g_value_unset(&xform);
}
else
{
- gval = val;
+ result = g_value_get_double(val);
}
- return g_value_get_double(gval);
+ return result;
}
gchar*
ghb_value_string(const GValue *val)
{
+ gchar *result;
+
if (val == NULL) return 0;
- const GValue *gval;
GValue xform = {0,};
if (G_VALUE_TYPE(val) != G_TYPE_STRING)
{
g_value_init(&xform, G_TYPE_STRING);
if (!g_value_transform(val, &xform))
return NULL;
- gval = &xform;
+ result = g_strdup(g_value_get_string(&xform));
+ g_value_unset(&xform);
}
else
{
- gval = val;
+ result = g_strdup(g_value_get_string(val));
}
- return g_strdup(g_value_get_string(gval));
+ return result;
}
gboolean
ghb_value_boolean(const GValue *val)
{
+ gboolean result;
+
if (val == NULL) return FALSE;
- const GValue *gval;
GValue xform = {0,};
if (G_VALUE_TYPE(val) != G_TYPE_BOOLEAN)
{
g_value_init(&xform, G_TYPE_BOOLEAN);
if (!g_value_transform(val, &xform))
return FALSE;
- gval = &xform;
+ result = g_value_get_boolean(&xform);
+ g_value_unset(&xform);
}
else
{
- gval = val;
+ result = g_value_get_boolean(val);
}
- return g_value_get_boolean(gval);
+ return result;
}
gint
@@ -446,9 +456,9 @@ ghb_value_set_combodata(
{
ghb_combodata_t combodata;
combodata.index = index;
- combodata.option = g_strdup(option);
- combodata.shortOpt = g_strdup(shortOpt);
- combodata.svalue = g_strdup(svalue);
+ combodata.option = (gchar*)option;
+ combodata.shortOpt = (gchar*)shortOpt;
+ combodata.svalue = (gchar*)svalue;
combodata.ivalue = ivalue;
g_value_set_boxed(gval, &combodata);
}