GtkTree and GtkThread: update and refresh



Hi! I have a problem about the update and refresh of a tree. This is the
situation: I have a populated tree and a button that update the tree. The
button's event calls a function that permorfs the following things:
1) Reset the treemodel appending a single text row "Loading"
2) Execute a db query
3) Reset the treemodel appending the results of the query
No errors, but a refresh problem. I can't see the text row "Loading" (1st
step); I can just see the new populated tree (3th step).

I could put the following code between the step 1 and 2:

          while(gtk_events_pending())
              gtk_main_iteration();

This solution works but it blocks the whole GUI.
A thread can help me for the GUI block and the pending events, but I have
another problem: after several clicks of the button the program blocks. I
don't know what happen: no errors, no segmentation fault.

Is it correct create a thread for each event of the button in that way?

            g_thread_create((GThreadFunc) loading_tree_and_the_fill_tree,
NULL, FALSE, &err)



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