]> granicus.if.org Git - handbrake/commitdiff
LinGui: yikes, this thing leaks worse than my roof, fixed
authorjstebbins <jstebbins.hb@gmail.com>
Mon, 8 Sep 2008 02:13:48 +0000 (02:13 +0000)
committerjstebbins <jstebbins.hb@gmail.com>
Mon, 8 Sep 2008 02:13:48 +0000 (02:13 +0000)
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1677 b64f7644-9d1e-0410-96f1-a4d463321fa5

gtk/src/callbacks.c
gtk/src/hb-backend.c
gtk/src/hb-backend.h
gtk/src/main.c
gtk/src/plist.c
gtk/src/presets.c
gtk/src/presets.h
gtk/src/settings.c
gtk/src/values.c

index 453fa693adbab967281051ab6c3888e33eb12254..c8c54175ae883f742d112aeb4d8314c8f1ba41fe 100644 (file)
@@ -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);
        }
index 44ca2346d16a5f7b44d35879d7436b4d17a317e8..d9f4cdbc510fe0cffd165a4622855ec6ada13ad5 100644 (file)
@@ -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;
@@ -1688,6 +1691,13 @@ ghb_backend_init(GtkBuilder *builder, gint debug, gint update)
        ghb_update_ui_combo_box(builder, NULL, 0, TRUE);
 }
 
+void
+ghb_backend_close()
+{
+       hb_close(&h_queue);
+       hb_close(&h_scan);
+}
+
 void
 ghb_backend_scan(const gchar *path, gint titleindex)
 {
index 2d04a00902059bf45c4c685965b14e03b66ab1c1..0972e1b102b4c0eee658b4e3d5d091474ef60dfb 100644 (file)
@@ -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);
index 02012b9bd11f4f6e013b0aa0338e433bf8b8a364..40307c8eb409e4a87816db77afb05e0eee0f83f1 100644 (file)
@@ -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;
 }
index b0a39c31b87996f8e00a14f3e7c4deb5247267df..d3dcf2af02049cab9edf0f6fcd68c7d29dd6eae6 100644 (file)
@@ -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:
                {
index 9052e1ec75f0706ac1827624ec5c5c62efc06c4d..e2b0eb21629f6c1d1a0e1b3a13d296e651318959 100644 (file)
@@ -593,6 +593,17 @@ ghb_settings_init(signal_user_data_t *ud)
        prefs_initializing = FALSE;
 }
 
+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)
 {
index b216c5580cd640ab14f2ed2c3647fca1ee0c3294..c8fbc50448f3ff9add5f8ca907db2a72d58d38de 100644 (file)
@@ -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);
index 1fad691ce6f4d5ba711feb3af1b9c913e6b7202e..d7b824bbb82d96fb34b298a13409d6cf0ca7d7dc 100644 (file)
@@ -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);
index b6be28af4adf86f6631b19f971b42234527f2f58..0f6c43285d135ae63049bd58ccbe4d5eedaeb4f1 100644 (file)
@@ -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);
 }