Re: threads/treeview



I don't know if it's related or not but I had a problem with
gdk_threads_init() a while back (see
http://mail.gnome.org/archives/gtk-app-devel-list/2002-February/msg00233.htm
l for more info).

My problem was that if I called gdk_threads_init() I couldn't later create
and show a file-selection dialog in a button-press callback.  It hung when I
tried to show the new widget (i.e. wouldn't respond to anything).  If I
removed the function call then everything was okay.

I never got an answer about this and am currently operating without the call
to gdk_threads_init() with no apparent problems.

Sorry that probably doesn't help much,
Richard.


----- Original Message -----
From: "Slyder" <slyder earendel org>
To: <gtk-app-devel-list gnome org>
Sent: Thursday, March 14, 2002 6:14 PM
Subject: threads/treeview


I seem to have run amuck of...something. I've pasted a small test program
below. Take out the call gdk_threads_init() and it works ok. Take out the
call to gtk_tree_view_insert_column_with_attributes() and it works ok.
Leave both in and it pops up the window, but wont respond to anything.
Have I done something foolish? Or have I stumbled across some insidious
little beastie of a bug? Oh, yes, I have 2.0.0 installed.

--------------------------------
#include <gtk/gtk.h>

int
main (int argc, char *argv[])
{
  GtkWidget *win, *vbox;
  GtkTreeStore *model;
  GtkWidget *view;
  GtkTreeViewColumn *column;
  GtkCellRenderer *cell_renderer;
  int col_off;

  gtk_init (&argc, &argv);
  g_thread_init (NULL);
  gdk_threads_init ();
  win = gtk_window_new (GTK_WINDOW_TOPLEVEL);
  g_signal_connect(G_OBJECT(win), "delete_event",
G_CALLBACK(gtk_main_quit), NULL);

  vbox = gtk_vbox_new (FALSE, 1);
  gtk_container_add (GTK_CONTAINER (win), vbox);
  model =
    gtk_tree_store_new (4, G_TYPE_STRING, G_TYPE_POINTER, G_TYPE_BOOLEAN,
G_TYPE_BOOLEAN);
  view = gtk_tree_view_new_with_model (GTK_TREE_MODEL (model));
  gtk_container_add (GTK_CONTAINER (vbox), view);
  g_object_unref (G_OBJECT (model));
  cell_renderer = gtk_cell_renderer_text_new ();
  /* **** this seems to be the line causing it */
  col_off = gtk_tree_view_insert_column_with_attributes
(GTK_TREE_VIEW(view),
                                                        -1, "Datasets",
                                                        cell_renderer,
                                                        "markup", 0,
NULL);

  gtk_widget_show_all (win);
  gdk_threads_enter ();
  gtk_main ();
  gdk_threads_leave ();
  return (0);
}

--
Slyder earendel org                  |  "Into the flood again...
Earendel / <insert here>             |   ...if I would, could you?"
Sing your dreams, Scream your song   |     --"Would", Alice in Chains
_______________________________________________
gtk-app-devel-list mailing list
gtk-app-devel-list gnome org
http://mail.gnome.org/mailman/listinfo/gtk-app-devel-list




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