Skip to content
Snippets Groups Projects
Commit 12f5e607 authored by Tristan Matthews's avatar Tristan Matthews
Browse files

* #10736: calltree: no more recursive calls

parent 1bc38feb
Branches
No related tags found
No related merge requests found
...@@ -550,6 +550,11 @@ typedef struct { ...@@ -550,6 +550,11 @@ typedef struct {
callable_obj_t *call; callable_obj_t *call;
} CallUpdateCtx; } CallUpdateCtx;
typedef struct {
calltab_t *tab;
const conference_obj_t *conf;
} ConferenceRemoveCtx;
static gboolean static gboolean
update_call(GtkTreeModel *model, GtkTreePath *path UNUSED, GtkTreeIter *iter, gpointer data) update_call(GtkTreeModel *model, GtkTreePath *path UNUSED, GtkTreeIter *iter, gpointer data)
{ {
...@@ -1004,36 +1009,32 @@ void calltree_add_conference_to_current_calls(conference_obj_t* conf) ...@@ -1004,36 +1009,32 @@ void calltree_add_conference_to_current_calls(conference_obj_t* conf)
} }
static static
void calltree_remove_conference_recursive(calltab_t* tab, const conference_obj_t* conf, GtkTreeIter *parent) gboolean
remove_conference(GtkTreeModel *model, GtkTreePath *path UNUSED, GtkTreeIter *iter, gpointer data)
{ {
GtkTreeModel *model = GTK_TREE_MODEL(tab->store); if (!is_conference(model, iter))
int nbChildren = gtk_tree_model_iter_n_children(model, parent); return FALSE;
for (int i = 0; i < nbChildren; i++) {
GtkTreeIter iter_parent;
/* if the nth child of parent has one or more children */
if (gtk_tree_model_iter_nth_child(model, &iter_parent, parent, i)) {
/* RECURSION! */
if (gtk_tree_model_iter_has_child(model, &iter_parent))
calltree_remove_conference_recursive(tab, conf, &iter_parent);
if (is_conference(model, &iter_parent)) {
gchar *conf_id; gchar *conf_id;
gtk_tree_model_get(model, &iter_parent, COLUMN_ID, &conf_id, -1); gtk_tree_model_get(model, iter, COLUMN_ID, &conf_id, -1);
ConferenceRemoveCtx * ctx = (ConferenceRemoveCtx *) data;
calltab_t *tab = ctx->tab;
conference_obj_t *tempconf = conferencelist_get(tab, conf_id); conference_obj_t *tempconf = conferencelist_get(tab, conf_id);
g_free(conf_id); g_free(conf_id);
/* if this is the conference we want to remove */ const conference_obj_t *conf = ctx->conf;
if (tempconf == conf) { /* if this is not the conference we want to remove */
int nbParticipants = gtk_tree_model_iter_n_children(model, &iter_parent); if (tempconf != conf)
return FALSE;
int nbParticipants = gtk_tree_model_iter_n_children(model, iter);
DEBUG("nbParticipants: %d", nbParticipants); DEBUG("nbParticipants: %d", nbParticipants);
for (int j = 0; j < nbParticipants; j++) { for (int j = 0; j < nbParticipants; j++) {
GtkTreeIter iter_child; GtkTreeIter iter_child;
if (gtk_tree_model_iter_nth_child(model, &iter_child, &iter_parent, j)) { if (gtk_tree_model_iter_nth_child(model, &iter_child, iter, j)) {
gchar *call_id; gchar *call_id;
gtk_tree_model_get(model, &iter_child, COLUMN_ID, &call_id, -1); gtk_tree_model_get(model, &iter_child, COLUMN_ID, &call_id, -1);
...@@ -1046,19 +1047,19 @@ void calltree_remove_conference_recursive(calltab_t* tab, const conference_obj_t ...@@ -1046,19 +1047,19 @@ void calltree_remove_conference_recursive(calltab_t* tab, const conference_obj_t
} }
} }
gtk_tree_store_remove(tab->store, &iter_parent); gtk_tree_store_remove(GTK_TREE_STORE(model), iter);
}
}
}
}
if (calltab_get_selected_conf(tab) == conf) if (calltab_get_selected_conf(tab) == conf)
calltab_select_conf(tab, NULL); calltab_select_conf(tab, NULL);
return TRUE;
} }
void calltree_remove_conference(calltab_t* tab, const conference_obj_t* conf) void calltree_remove_conference(calltab_t* tab, const conference_obj_t* conf)
{ {
calltree_remove_conference_recursive(tab, conf, NULL); ConferenceRemoveCtx context = {tab, conf};
GtkTreeStore *store = tab->store;
GtkTreeModel *model = GTK_TREE_MODEL(store);
gtk_tree_model_foreach(model, remove_conference, (gpointer) &context);
update_actions(); update_actions();
DEBUG("Finished removing conference %s", conf->_confID); DEBUG("Finished removing conference %s", conf->_confID);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment