#include <sys/wait.h>
#endif
+#include <string.h>
+
/* best effort to make things compile and possibly even work on win32 */
#ifndef WEXITSTATUS
# define WEXITSTATUS(status) ((((guint)(status)) & 0xff00) >> 8)
}
static gboolean
+ptr_array_contains_string (GPtrArray * arr, const gchar * s)
+{
+ gint i;
+
+ for (i = 0; i < arr->len; ++i) {
+ if (strcmp ((const char *) g_ptr_array_index (arr, i), s) == 0)
+ return TRUE;
+ }
+ return FALSE;
+}
+
+static gboolean
gst_install_plugins_spawn_child (gchar ** details,
GstInstallPluginsContext * ctx, GPid * child_pid, gint * exit_status)
{
g_ptr_array_add (arr, xid_str);
}
- /* finally, add the detail strings */
+ /* finally, add the detail strings, but without duplicates */
while (details != NULL && details[0] != NULL) {
- g_ptr_array_add (arr, details[0]);
+ if (!ptr_array_contains_string (arr, details[0]))
+ g_ptr_array_add (arr, details[0]);
++details;
}
GstInstallPluginsContext *ctx;
GstInstallPluginsReturn ret;
gchar *details[] = { "detail1", "detail2", NULL };
+ gchar *details_multi[] = { "detail1", "detail1", "detail2", NULL };
ctx = gst_install_plugins_context_new ();
test_pb_utils_install_plugins_do_callout (details, ctx, SCRIPT_WITH_XID,
GST_INSTALL_PLUGINS_SUCCESS);
+ /* and make sure that duplicate detail strings get dropped */
+ test_pb_utils_install_plugins_do_callout (details_multi, NULL, SCRIPT_NO_XID,
+ GST_INSTALL_PLUGINS_NOT_FOUND);
+
+ /* and the same again with context */
+ gst_install_plugins_context_set_xid (ctx, 42);
+ test_pb_utils_install_plugins_do_callout (details_multi, ctx, SCRIPT_WITH_XID,
+ GST_INSTALL_PLUGINS_SUCCESS);
+
/* and free the context now that we don't need it any longer */
gst_install_plugins_context_free (ctx);