Hmm looks like gtk_tree_store_remove is broken?



If I'm removing all child node in a parent node and append new
again (in the same parent node) the newly inserted node doesn't show:

Example:

  GtkTreeIter iter,parentiter;
  int selid = 1;

   /* lookup the parent object */ 
   /* returns TRUE on success */  	
  if (!tree_find_albumid(selid, &parentiter))
  {
	cout << "didn't find album iterator???" << endl;
	return ;
  }

  /* remove all child objects to parentiter */
 
  while (gtk_tree_model_iter_children(treemodel, &iter,&piter))
    gtk_tree_store_remove(GTK_TREE_STORE(treemodel), &iter);

  /* now when were empty try insert some new again but first we
     make sure parent iter really is pointing correcly: */ 


  if (!tree_find_albumid(selid, &parentiter))
  {
	cout << "did't find album iterator" << endl;
	return ;
  }
  
 
  /* for some reason below code does NOT WORK ??? */ 
  /* because the newly inserted node doesn't show??? */

  gtk_tree_store_append(GTK_TREE_STORE(*treemodel), &iter, &parentiter);

  
bool MyApp::tree_find_albumid(int id, GtkTreeIter *iter)
{
  gchar *txt[1];
  gtk_tree_model_get_first(treemodel, iter);
  do  {
    gtk_tree_model_get(treemodel, iter, 0, txt, -1);
    if(id == atoi(txt[0]))  {
      g_free(txt[0]);
      return true;
    }

    g_free(txt[0]);
  }  while(gtk_tree_model_iter_next(treemodel,iter));

  return false;
}




[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]