summaryrefslogtreecommitdiffstats
path: root/gtk
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2014-10-29 23:04:11 +0000
committerjstebbins <[email protected]>2014-10-29 23:04:11 +0000
commit238f2aeca97a566a243bc96a5fd5c78a2cae5a3c (patch)
treead15605087a74c2aaacaa08179a33a30a3cbf532 /gtk
parent387a47a9e2704ec4bd0b29d40859cff295de3b69 (diff)
LinGui: fix several small memory leaks
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@6479 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk')
-rw-r--r--gtk/src/callbacks.c5
-rw-r--r--gtk/src/presets.c40
-rw-r--r--gtk/src/queuehandler.c18
-rw-r--r--gtk/src/subtitlehandler.c22
-rw-r--r--gtk/src/subtitlehandler.h1
5 files changed, 50 insertions, 36 deletions
diff --git a/gtk/src/callbacks.c b/gtk/src/callbacks.c
index 3859cbefa..5f9183db6 100644
--- a/gtk/src/callbacks.c
+++ b/gtk/src/callbacks.c
@@ -567,9 +567,9 @@ check_name_template(signal_user_data_t *ud, const char *str)
{
if (ghb_settings_get_boolean(ud->prefs, "auto_name"))
{
- gchar *template;
+ const gchar *template;
- template = ghb_settings_get_string(ud->prefs, "auto_name_template");
+ template = ghb_settings_get_const_string(ud->prefs, "auto_name_template");
if (strstr(template, str) != NULL)
return TRUE;
}
@@ -1811,6 +1811,7 @@ set_title_settings(signal_user_data_t *ud, GValue *settings)
title_id = ghb_settings_get_int(settings, "title");
title = ghb_lookup_title(title_id, &titleindex);
+ ghb_subtitle_set_pref_lang(settings);
if (title != NULL)
{
gint num_chapters = hb_list_count(title->list_chapter);
diff --git a/gtk/src/presets.c b/gtk/src/presets.c
index 01692a68a..e5a5b65b4 100644
--- a/gtk/src/presets.c
+++ b/gtk/src/presets.c
@@ -1148,6 +1148,7 @@ ghb_get_user_config_dir(gchar *subdir)
if (!g_file_test(config, G_FILE_TEST_IS_DIR))
g_mkdir (config, 0755);
}
+ g_strfreev(split);
}
return config;
}
@@ -2638,7 +2639,7 @@ import_xlat_preset(GValue *user_preset)
} break;
}
- gchar *mode = ghb_settings_get_string(dict, "VideoFramerateMode");
+ const gchar *mode = ghb_settings_get_const_string(dict, "VideoFramerateMode");
if (strcmp(mode, "cfr") == 0)
{
ghb_settings_set_boolean(dict, "VideoFramerateCFR", TRUE);
@@ -2657,7 +2658,6 @@ import_xlat_preset(GValue *user_preset)
ghb_settings_set_boolean(dict, "VideoFrameratePFR", FALSE);
ghb_settings_set_boolean(dict, "VideoFramerateVFR", TRUE);
}
- g_free(mode);
if (ghb_settings_get_boolean(dict, "x264UseAdvancedOptions"))
{
@@ -2730,26 +2730,26 @@ import_xlat_preset(GValue *user_preset)
g_free(tune);
}
- char *videoProfile;
+ const char *videoProfile;
if (ghb_dict_lookup(user_preset, "x264Profile") != NULL)
- videoProfile = ghb_settings_get_string(dict, "x264Profile");
+ videoProfile = ghb_settings_get_const_string(dict, "x264Profile");
else
- videoProfile = ghb_settings_get_string(dict, "VideoProfile");
+ videoProfile = ghb_settings_get_const_string(dict, "VideoProfile");
if (videoProfile != NULL)
ghb_settings_set_string(dict, "VideoProfile", videoProfile);
- char *videoLevel;
+ const char *videoLevel;
if (ghb_dict_lookup(user_preset, "x264Level") != NULL)
- videoLevel = ghb_settings_get_string(dict, "x264Level");
+ videoLevel = ghb_settings_get_const_string(dict, "x264Level");
else
- videoLevel = ghb_settings_get_string(dict, "VideoLevel");
+ videoLevel = ghb_settings_get_const_string(dict, "VideoLevel");
if (videoLevel != NULL)
ghb_settings_set_string(dict, "VideoLevel", videoLevel);
if (ghb_dict_lookup(user_preset, "x264OptionExtra") != NULL)
{
- char *optionExtra;
- optionExtra = ghb_settings_get_string(dict, "x264OptionExtra");
+ const char *optionExtra;
+ optionExtra = ghb_settings_get_const_string(dict, "x264OptionExtra");
ghb_settings_set_string(dict, "VideoOptionExtra", optionExtra);
}
@@ -3389,7 +3389,7 @@ preset_import_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
{
GtkWidget *dialog;
GtkResponseType response;
- gchar *exportDir;
+ const gchar *exportDir;
gchar *filename;
GtkFileFilter *filter;
@@ -3412,13 +3412,12 @@ preset_import_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
gtk_file_chooser_add_filter(GTK_FILE_CHOOSER(dialog), filter);
gtk_file_chooser_set_filter(GTK_FILE_CHOOSER(dialog), filter);
- exportDir = ghb_settings_get_string(ud->prefs, "ExportDirectory");
+ exportDir = ghb_settings_get_const_string(ud->prefs, "ExportDirectory");
if (exportDir == NULL || exportDir[0] == '\0')
{
- exportDir = g_strdup(".");
+ exportDir = ".";
}
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), exportDir);
- g_free(exportDir);
response = gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_hide(dialog);
@@ -3481,7 +3480,7 @@ preset_import_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
}
ghb_value_free(array);
- exportDir = ghb_settings_get_string(ud->prefs, "ExportDirectory");
+ exportDir = ghb_settings_get_const_string(ud->prefs, "ExportDirectory");
dir = g_path_get_dirname(filename);
if (strcmp(dir, exportDir) != 0)
{
@@ -3489,7 +3488,6 @@ preset_import_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
ghb_pref_save(ud->prefs, "ExportDirectory");
}
g_free(filename);
- g_free(exportDir);
g_free(dir);
store_presets();
}
@@ -3530,7 +3528,7 @@ preset_export_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
GValue *preset;
const gchar *name = "";
gint count, *indices, len;
- gchar *exportDir;
+ const gchar *exportDir;
gchar *filename;
g_debug("preset_export_clicked_cb ()");
@@ -3553,16 +3551,15 @@ preset_export_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
GHB_STOCK_SAVE, GTK_RESPONSE_ACCEPT,
NULL);
- exportDir = ghb_settings_get_string(ud->prefs, "ExportDirectory");
+ exportDir = ghb_settings_get_const_string(ud->prefs, "ExportDirectory");
if (exportDir == NULL || exportDir[0] == '\0')
{
- exportDir = g_strdup(".");
+ exportDir = ".";
}
filename = g_strdup_printf("%s.plist", name);
gtk_file_chooser_set_current_folder(GTK_FILE_CHOOSER(dialog), exportDir);
gtk_file_chooser_set_current_name(GTK_FILE_CHOOSER(dialog), filename);
g_free(filename);
- g_free(exportDir);
indices = ghb_preset_indices_from_path(presetsPlist, preset, &len);
if (indices == NULL)
@@ -3599,14 +3596,13 @@ preset_export_clicked_cb(GtkWidget *xwidget, signal_user_data_t *ud)
}
ghb_value_free(array);
- exportDir = ghb_settings_get_string(ud->prefs, "ExportDirectory");
+ exportDir = ghb_settings_get_const_string(ud->prefs, "ExportDirectory");
dir = g_path_get_dirname(filename);
if (strcmp(dir, exportDir) != 0)
{
ghb_settings_set_string(ud->prefs, "ExportDirectory", dir);
ghb_pref_save(ud->prefs, "ExportDirectory");
}
- g_free(exportDir);
g_free(dir);
g_free(filename);
}
diff --git a/gtk/src/queuehandler.c b/gtk/src/queuehandler.c
index 45e14e8e2..4f667cf7c 100644
--- a/gtk/src/queuehandler.c
+++ b/gtk/src/queuehandler.c
@@ -781,7 +781,8 @@ validate_settings(signal_user_data_t *ud, GValue *settings, gint batch)
{
// Check to see if the dest file exists or is
// already in the queue
- gchar *message, *dest;
+ gchar *message;
+ const gchar *dest;
gint count, ii;
gint title_id, titleindex;
const hb_title_t *title;
@@ -789,15 +790,15 @@ validate_settings(signal_user_data_t *ud, GValue *settings, gint batch)
title_id = ghb_settings_get_int(settings, "title");
title = ghb_lookup_title(title_id, &titleindex);
if (title == NULL) return FALSE;
- dest = ghb_settings_get_string(settings, "destination");
+ dest = ghb_settings_get_const_string(settings, "destination");
count = ghb_array_len(ud->queue);
for (ii = 0; ii < count; ii++)
{
GValue *js;
- gchar *filename;
+ const gchar *filename;
js = ghb_array_get_nth(ud->queue, ii);
- filename = ghb_settings_get_string(js, "destination");
+ filename = ghb_settings_get_const_string(js, "destination");
if (strcmp(dest, filename) == 0)
{
message = g_strdup_printf(
@@ -807,15 +808,12 @@ validate_settings(signal_user_data_t *ud, GValue *settings, gint batch)
dest);
if (!ghb_message_dialog(GTK_MESSAGE_QUESTION, message, _("Cancel"), _("Overwrite")))
{
- g_free(filename);
- g_free(dest);
g_free(message);
return FALSE;
}
g_free(message);
break;
}
- g_free(filename);
}
gchar *destdir = g_path_get_dirname(dest);
if (!g_file_test(destdir, G_FILE_TEST_IS_DIR))
@@ -825,7 +823,6 @@ validate_settings(signal_user_data_t *ud, GValue *settings, gint batch)
"This is not a valid directory."),
destdir);
ghb_message_dialog(GTK_MESSAGE_ERROR, message, _("Cancel"), NULL);
- g_free(dest);
g_free(message);
g_free(destdir);
return FALSE;
@@ -839,7 +836,6 @@ validate_settings(signal_user_data_t *ud, GValue *settings, gint batch)
"Can not read or write the directory."),
destdir);
ghb_message_dialog(GTK_MESSAGE_ERROR, message, _("Cancel"), NULL);
- g_free(dest);
g_free(message);
g_free(destdir);
return FALSE;
@@ -871,8 +867,8 @@ validate_settings(signal_user_data_t *ud, GValue *settings, gint batch)
(guint)(size / (1024L*1024L)));
if (!ghb_message_dialog(GTK_MESSAGE_QUESTION, message, _("Cancel"), _("Proceed")))
{
- g_free(dest);
g_free(message);
+ g_free(destdir);
return FALSE;
}
g_free(message);
@@ -893,14 +889,12 @@ validate_settings(signal_user_data_t *ud, GValue *settings, gint batch)
dest);
if (!ghb_message_dialog(GTK_MESSAGE_QUESTION, message, _("Cancel"), _("Overwrite")))
{
- g_free(dest);
g_free(message);
return FALSE;
}
g_free(message);
g_unlink(dest);
}
- g_free(dest);
// Validate audio settings
if (!ghb_validate_audio(settings))
{
diff --git a/gtk/src/subtitlehandler.c b/gtk/src/subtitlehandler.c
index dd4faef4b..0c3933dd1 100644
--- a/gtk/src/subtitlehandler.c
+++ b/gtk/src/subtitlehandler.c
@@ -1336,6 +1336,28 @@ subtitle_update_pref_lang(signal_user_data_t *ud, const iso639_lang_t *lang)
gtk_widget_set_visible(GTK_WIDGET(button), visible);
}
+void
+ghb_subtitle_set_pref_lang(GValue *settings)
+{
+ GValue *lang_list;
+ gboolean set = FALSE;
+ lang_list = ghb_settings_get_value(settings, "SubtitleLanguageList");
+ if (ghb_array_len(lang_list) > 0)
+ {
+ GValue *glang = ghb_array_get_nth(lang_list, 0);
+ if (glang != NULL)
+ {
+ ghb_settings_set_string(settings, "PreferredLanguage",
+ g_value_get_string(glang));
+ set = TRUE;
+ }
+ }
+ if (!set)
+ {
+ ghb_settings_set_string(settings, "PreferredLanguage", "und");
+ }
+}
+
G_MODULE_EXPORT void
subtitle_add_lang_clicked_cb(GtkWidget *widget, signal_user_data_t *ud)
{
diff --git a/gtk/src/subtitlehandler.h b/gtk/src/subtitlehandler.h
index 0569be89e..74c5f7f69 100644
--- a/gtk/src/subtitlehandler.h
+++ b/gtk/src/subtitlehandler.h
@@ -36,5 +36,6 @@ void ghb_subtitle_list_refresh_all(signal_user_data_t *ud);
void ghb_init_subtitle_defaults_ui(signal_user_data_t *ud);
void ghb_subtitle_defaults_to_ui(signal_user_data_t *ud);
void ghb_subtitle_title_change(signal_user_data_t *ud, gboolean show);
+void ghb_subtitle_set_pref_lang(GValue *settings);
#endif // _SUBTITLEHANDLER_H_