1

I've been trying to figure out some method to cause a GtkTreeView to redraw after I update the bound GtkListStore from a background thread created with pthreads.

Generally, the widget does not update until something obscures an existing row (even a mouse cursor ).

Most of my searches for this problem has "your tree model doesn't/isn't generating the correct signals" ....

I'm running an old Red Hat 9 with gtk+ 2.0.0, for industrial embedded applications. Most of the data comes from ipc/socket/pipes and gets displayed by a GTK app. Unfortunately so does CRITICAL alarms, which has a habit of not showing when they should. We will (one day) move to a current kernel, but I need to get something working with the existing software.

I've tried emiting the "row-changed" signals, tried calling the gtk_widget_queue_draw and also tried connecting to the "expose-event", where I've tried various things that don't work or seg fault.

server.c

bool Server::Start()
{
 // .... 
 // pthread_t _id;
 //
 pthread_create( & _id, NULL, &StaticServerThread, this );
 // ....
}

viewer.c

bool Viewer::ReadFinished( SocketArgs * args )
{
 gdk_threads_enter();

 // Populate the buffer and message
 //
 // GtkListStore *_outputStore;
 // gchar        *buffer;
 // gchar        *message;

 GtkTreeIter iter;
 gtk_list_store_insert_with_values( _outputStore, &iter, 0, 
                    0, buffer, 1, message, -1 );

 // ....
 gdk_threads_leave();
}
  • I'm not sure that GDK threads supports interoperating with plain old pthreads (even though GDK threads uses pthreads on Linux); did you try with `g_thread_create` and friends? – ptomato Aug 08 '12 at 21:14

1 Answers1

1

You can perform the updates to the list store in the main thread. For example, you can use g_idle_add() in the worker thread.

jeffmagill
  • 191
  • 1
  • 6