summaryrefslogtreecommitdiffstats
path: root/gtk/src/presets.c
diff options
context:
space:
mode:
authorjstebbins <[email protected]>2008-09-07 17:06:39 +0000
committerjstebbins <[email protected]>2008-09-07 17:06:39 +0000
commitb97863af3eb0b376403de71d89b070d65b6bbe9b (patch)
tree50d537dbb11c6f1ebd3febf095dc3932401563a6 /gtk/src/presets.c
parent5917f628bf5aa7d6c19aa4bb67588ef064dc709c (diff)
LinGui: Fix several strict-aliasing warnings and a null pointer dereference
that can happen if preferences don't yet exist and your running the app over an ssh session. git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1673 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'gtk/src/presets.c')
-rw-r--r--gtk/src/presets.c69
1 files changed, 56 insertions, 13 deletions
diff --git a/gtk/src/presets.c b/gtk/src/presets.c
index 8f032d819..9052e1ec7 100644
--- a/gtk/src/presets.c
+++ b/gtk/src/presets.c
@@ -213,7 +213,10 @@ init_settings_from_dict(
GValue *gval, *val;
ghb_dict_iter_init(&iter, internal);
- while (g_hash_table_iter_next(&iter, (gpointer*)&key, (gpointer*)&gval))
+ // middle (void*) cast prevents gcc warning "defreferencing type-punned
+ // pointer will break strict-aliasing rules"
+ while (g_hash_table_iter_next(
+ &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval))
{
val = NULL;
if (dict)
@@ -259,7 +262,10 @@ init_ui_from_dict(
GValue *gval, *val;
ghb_dict_iter_init(&iter, internal);
- while (g_hash_table_iter_next(&iter, (gpointer*)&key, (gpointer*)&gval))
+ // middle (void*) cast prevents gcc warning "defreferencing type-punned
+ // pointer will break strict-aliasing rules"
+ while (g_hash_table_iter_next(
+ &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval))
{
val = NULL;
if (dict)
@@ -427,7 +433,10 @@ ghb_prefs_to_ui(signal_user_data_t *ud)
// then update the ui.
internal = plist_get_dict(internalPlist, "Initialization");
ghb_dict_iter_init(&iter, internal);
- while (g_hash_table_iter_next(&iter, (gpointer*)&key, (gpointer*)&gval))
+ // middle (void*) cast prevents gcc warning "defreferencing type-punned
+ // pointer will break strict-aliasing rules"
+ while (g_hash_table_iter_next(
+ &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval))
{
ghb_ui_update(ud, key, gval);
}
@@ -435,7 +444,10 @@ ghb_prefs_to_ui(signal_user_data_t *ud)
dict = plist_get_dict(prefsPlist, "Preferences");
internal = plist_get_dict(internalPlist, "Preferences");
ghb_dict_iter_init(&iter, internal);
- while (g_hash_table_iter_next(&iter, (gpointer*)&key, (gpointer*)&gval))
+ // middle (void*) cast prevents gcc warning "defreferencing type-punned
+ // pointer will break strict-aliasing rules"
+ while (g_hash_table_iter_next(
+ &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval))
{
const GValue *value = NULL;
if (dict)
@@ -446,7 +458,10 @@ ghb_prefs_to_ui(signal_user_data_t *ud)
}
internal = plist_get_dict(internalPlist, "Preferences");
ghb_dict_iter_init(&iter, internal);
- while (g_hash_table_iter_next(&iter, (gpointer*)&key, (gpointer*)&gval))
+ // middle (void*) cast prevents gcc warning "defreferencing type-punned
+ // pointer will break strict-aliasing rules"
+ while (g_hash_table_iter_next(
+ &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval))
{
const GValue *value = NULL;
if (dict)
@@ -497,7 +512,10 @@ ghb_prefs_save(GValue *settings)
pref_dict = plist_get_dict(prefsPlist, "Preferences");
if (pref_dict == NULL) return;
ghb_dict_iter_init(&iter, dict);
- while (g_hash_table_iter_next(&iter, (gpointer*)&key, (gpointer*)&value))
+ // middle (void*) cast prevents gcc warning "defreferencing type-punned
+ // pointer will break strict-aliasing rules"
+ while (g_hash_table_iter_next(
+ &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&value))
{
value = ghb_settings_get_value(settings, key);
if (value != NULL)
@@ -545,21 +563,30 @@ ghb_settings_init(signal_user_data_t *ud)
// then update the ui.
internal = plist_get_dict(internalPlist, "Initialization");
ghb_dict_iter_init(&iter, internal);
- while (g_hash_table_iter_next(&iter, (gpointer*)&key, (gpointer*)&gval))
+ // middle (void*) cast prevents gcc warning "defreferencing type-punned
+ // pointer will break strict-aliasing rules"
+ while (g_hash_table_iter_next(
+ &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval))
{
ghb_settings_set_value(ud->settings, key, gval);
}
internal = plist_get_dict(internalPlist, "Presets");
ghb_dict_iter_init(&iter, internal);
- while (g_hash_table_iter_next(&iter, (gpointer*)&key, (gpointer*)&gval))
+ // middle (void*) cast prevents gcc warning "defreferencing type-punned
+ // pointer will break strict-aliasing rules"
+ while (g_hash_table_iter_next(
+ &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval))
{
ghb_settings_set_value(ud->settings, key, gval);
}
internal = plist_get_dict(internalPlist, "Preferences");
ghb_dict_iter_init(&iter, internal);
- while (g_hash_table_iter_next(&iter, (gpointer*)&key, (gpointer*)&gval))
+ // middle (void*) cast prevents gcc warning "defreferencing type-punned
+ // pointer will break strict-aliasing rules"
+ while (g_hash_table_iter_next(
+ &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval))
{
ghb_settings_set_value(ud->settings, key, gval);
}
@@ -587,11 +614,18 @@ ghb_prefs_load(signal_user_data_t *ud)
// Get defaults from internal defaults
ghb_dict_iter_init(&iter, internal);
- while (g_hash_table_iter_next(&iter, (gpointer*)&key, (gpointer*)&gval))
+ // middle (void*) cast prevents gcc warning "defreferencing type-punned
+ // pointer will break strict-aliasing rules"
+ while (g_hash_table_iter_next(
+ &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&gval))
{
ghb_dict_insert(dict, g_strdup(key), ghb_value_dup(gval));
}
const gchar *dir = g_get_user_special_dir (G_USER_DIRECTORY_VIDEOS);
+ if (dir == NULL)
+ {
+ dir = ".";
+ }
ghb_dict_insert(dict,
g_strdup("destination_dir"), ghb_value_dup(ghb_string_value(dir)));
store_plist(prefsPlist, "preferences");
@@ -613,7 +647,10 @@ ghb_presets_reload(signal_user_data_t *ud)
GValue *orig_dict;
ghb_dict_iter_init(&std_iter, std_dict);
- while (g_hash_table_iter_next(&std_iter, (gpointer*)&name, (gpointer*)&orig_dict))
+ // middle (void*) cast prevents gcc warning "defreferencing type-punned
+ // pointer will break strict-aliasing rules"
+ while (g_hash_table_iter_next(
+ &std_iter, (gpointer*)(void*)&name, (gpointer*)(void*)&orig_dict))
{
GHashTableIter iter;
gchar *key;
@@ -622,7 +659,10 @@ ghb_presets_reload(signal_user_data_t *ud)
dict = ghb_dict_value_new();
ghb_dict_insert(presetsPlist, g_strdup(name), dict);
ghb_dict_iter_init(&iter, orig_dict);
- while (g_hash_table_iter_next(&iter, (gpointer*)&key, (gpointer*)&value))
+ // middle (void*) cast prevents gcc warning "defreferencing type-punned
+ // pointer will break strict-aliasing rules"
+ while (g_hash_table_iter_next(
+ &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&value))
{
ghb_dict_insert(dict, g_strdup(key), ghb_value_dup(value));
}
@@ -702,7 +742,10 @@ ghb_settings_save(signal_user_data_t *ud, const gchar *name)
internal = plist_get_dict(internalPlist, "Presets");
ghb_dict_iter_init(&iter, internal);
- while (g_hash_table_iter_next(&iter, (gpointer*)&key, (gpointer*)&value))
+ // middle (void*) cast prevents gcc warning "defreferencing type-punned
+ // pointer will break strict-aliasing rules"
+ while (g_hash_table_iter_next(
+ &iter, (gpointer*)(void*)&key, (gpointer*)(void*)&value))
{
if (!autoscale)
{