- g_ptr_array_add(graph->components, upstream_component);
- g_ptr_array_add(graph->components, downstream_component);
- if (bt_component_get_class_type(downstream_component) ==
- BT_COMPONENT_CLASS_TYPE_SINK) {
- g_queue_push_tail(graph->sinks_to_consume,
- downstream_component);
+
+ if (!upstream_was_already_in_graph) {
+ g_ptr_array_add(graph->components, upstream_component);
+ bt_component_set_graph(upstream_component, graph);
+ }
+ if (!downstream_was_already_in_graph) {
+ g_ptr_array_add(graph->components, downstream_component);
+ bt_component_set_graph(downstream_component, graph);
+ if (bt_component_get_class_type(downstream_component) ==
+ BT_COMPONENT_CLASS_TYPE_SINK) {
+ g_queue_push_tail(graph->sinks_to_consume,
+ downstream_component);
+ }