modification on treeview blocks or crashes if using g_threads
- From: Martin SCHREIBER <martin schreiber in tum de>
- To: gtk-devel-list gnome org
- Subject: modification on treeview blocks or crashes if using g_threads
- Date: Thu, 07 Feb 2008 16:07:36 +0100
hi there,
i'm not sure if this is a bug so i'm going to post this here and ask for
your advice.
maybe there's a mistake in using the g_threads in the attached program?
there are 2 ways how the program sucks:
1) sometimes it just hangs up directly after start. if i move parts of
the window over the screenborder and back, the graphic isnt restored.
2) sometimes it updates the list (as it should be) but if i click on the
list a lot of times i get the following error message:
** ERROR **: file gailtreeview.c: line 3755 (traverse_cells): assertion
failed: (row_path != NULL)
and the program aborts.
greez,
martin
--
Martin Schreiber
http://www.martin-schreiber.net
| Im Muehltal 48
| 91171 Greding
| GERMANY
/*
* Compile with:
* gcc -o helloworld helloworld.c `pkg-config --cflags --libs gtk+-2.0` -lgthread-2.0
*
*/
#include <gtk/gtk.h>
GtkListStore *store;
GtkTreeModel *model;
static GtkWidget *
create_view_and_model (void)
{
GtkCellRenderer *renderer;
GtkWidget *view;
view = gtk_tree_view_new ();
renderer = gtk_cell_renderer_text_new ();
gtk_tree_view_insert_column_with_attributes (GTK_TREE_VIEW (view),
-1,
"Name",
renderer,
"text", 0,
NULL);
store = gtk_list_store_new (1, G_TYPE_STRING);
model = GTK_TREE_MODEL (store);
gtk_tree_view_set_model (GTK_TREE_VIEW (view), model);
g_object_unref (model);
return view;
}
void *threadLoop(void *asdf)
{
while(1)
{
gdk_threads_enter();
GtkTreeIter iter;
gtk_list_store_clear(store);
for (int i = 0; i < 10; i++)
{
gtk_list_store_append( store, &iter);
gtk_list_store_set( store, &iter,
0, "TEST TEST TEST TEST TEST TEST TEST TEST TEST TEST",
-1);
}
gdk_threads_leave();
}
}
int
main (int argc, char **argv)
{
g_thread_init(NULL);
gdk_threads_init();
gdk_threads_enter();
GtkWidget *window;
GtkWidget *view;
gtk_init (&argc, &argv);
window = gtk_window_new (GTK_WINDOW_TOPLEVEL);
g_signal_connect (window, "delete_event", gtk_main_quit, NULL); /* dirty */
view = create_view_and_model ();
gtk_container_add (GTK_CONTAINER (window), view);
gtk_widget_show_all (window);
g_thread_create(&threadLoop, 0, true, 0);
gtk_main ();
gdk_threads_leave();
return 0;
}
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]