changeset 31153:2b63df6e495c

vvconfig: Don't crash when the stored device isn't found in the list of available devices. Fixes #13238. committer: John Bailey <rekkanoryo@rekkanoryo.org>
author jakub.adam@ktknet.cz
date Sat, 22 Jan 2011 08:42:12 +0000
parents 66fe4bda9a85
children b5714a933dcc
files ChangeLog pidgin/plugins/vvconfig.c
diffstat 2 files changed, 9 insertions(+), 20 deletions(-) [+]
line wrap: on
line diff
--- a/ChangeLog	Sat Jan 22 08:32:31 2011 +0000
+++ b/ChangeLog	Sat Jan 22 08:42:12 2011 +0000
@@ -36,6 +36,9 @@
 	Plugins:
 	* The Voice/Video Settings plugin no longer resets selected devices to
 	  defaults. (Jakub Adam) (#13044)
+	* The Voice/Video Settings plugin no longer crashes when a stored device
+	  name is not found in the list of available devices. (Jakub Adam)
+	  (#13238)
 	* The Autoaccept plugin now allows disabling filename escaping. (Rok
 	  Mandeljc) (half of #11459)
 	* The Autoaccept plugin now allows choosing Reject/Ask/Accept for
--- a/pidgin/plugins/vvconfig.c	Sat Jan 22 08:32:31 2011 +0000
+++ b/pidgin/plugins/vvconfig.c	Sat Jan 22 08:42:12 2011 +0000
@@ -82,20 +82,11 @@
 	GstPropertyProbe *probe;
 	const GParamSpec *pspec;
 
-	if (!strcmp(element_name, "<custom>")) {
-		ret = g_list_prepend(ret, NULL);
-		ret = g_list_prepend(ret, (gpointer)_("Default"));
-		ret = g_list_prepend(ret, "");
-		return ret;
-	}
-
 	ret = g_list_prepend(ret, (gpointer)_("Default"));
 	ret = g_list_prepend(ret, "");
 
-	if (*element_name == '\0') {
-		ret = g_list_prepend(ret, NULL);
-		ret = g_list_reverse(ret);
-		return ret;
+	if (!strcmp(element_name, "<custom>") || (*element_name == '\0')) {
+		return g_list_reverse(ret);
 	}
 
 	element = gst_element_factory_make(element_name, "test");
@@ -120,9 +111,7 @@
 		array = gst_property_probe_probe_and_get_values (probe, pspec);
 		if (array == NULL) {
 			purple_debug_info("vvconfig", "'%s' has no devices\n", element_name);
-			ret = g_list_prepend(ret, NULL);
-			ret = g_list_reverse(ret);
-			return ret;
+			return g_list_reverse(ret);
 		}
 
 		for (n=0; n < array->n_values; ++n) {
@@ -153,10 +142,7 @@
 	}
 	gst_object_unref(element);
 
-	ret = g_list_prepend(ret, NULL);
-	ret = g_list_reverse(ret);
-
-	return ret;
+	return g_list_reverse(ret);
 }
 
 static GList *
@@ -173,7 +159,6 @@
 			ret = g_list_prepend(ret, (gpointer)plugins[0]);
 		}
 	}
-	ret = g_list_prepend(ret, NULL);
 	ret = g_list_reverse(ret);
 	return ret;
 }
@@ -236,7 +221,8 @@
 	pref = g_strdup(name);
 	strcpy(pref + strlen(pref) - strlen("plugin"), "device");
 	devices = get_element_devices(value);
-	if (g_list_find(devices, purple_prefs_get_string(pref)) == NULL)
+	if (g_list_find_custom(devices, purple_prefs_get_string(pref),
+			(GCompareFunc)strcmp) == NULL)
 		purple_prefs_set_string(pref, g_list_next(devices)->data);
 	widget = pidgin_prefs_dropdown_from_list(parent,
 			label, PURPLE_PREF_STRING,