Date: Mon, 13 Oct 2003 14:30:20 +0100 To: lablgtk at kaba.or.jp Subject: Bug when changing the contents of a frame Message-ID: <20031013133019.GA26162 at redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline From: Richard Jones The minimal possible case I've been able to find is below. I'm trying to have a frame which will contain different widgets depending on context (simulated by pressing buttons in the example below). Everything works fine if the frame contains only simple widgets, eg. a single button or label. However if I try to add complex widgets (eg. vbox containing more than one widget), then the program crashes when removing the complex widget. The error is: Fatal error: exception Glib.Critical("Gtk", "file gtkcontainer.c: line 984 (gtk_container_remove): assertion `widget->parent == GTK_WIDGET (container)' failed") How can I do this? Rich. ---------------------------------------------------------------------- (* $Id: frameparent.ml,v 1.3 2003/10/13 13:26:14 rich Exp $ *) (* ocamlc -g -w s -I +lablgtk2 lablgtk.cma gtkInit.cmo frameparent.ml -o frameparent *) let () = let dialog = GWindow.dialog () in let vbox = dialog#vbox in let action_area = dialog#action_area in let frame = GBin.frame ~width:200 ~height:200 ~packing:vbox#pack () in let show i = (match i with 1 -> GMisc.label ~text:"Label 1" ~packing:frame#add () | 2 -> let vbox = GPack.vbox ~packing:frame#add () in GMisc.label ~text:"A label" ~packing:vbox#pack (); GMisc.label ~text:"Another label" ~packing:vbox#pack () | _ -> GMisc.label ~text:"Label 3" ~packing:frame#add () :> GObj.widget) in let w = ref (show 1) in let remove () = frame#remove !w in let b1 = GButton.button ~label:"Show Label 1" ~packing:action_area#pack () in let b2 = GButton.button ~label:"Show Label 2" ~packing:action_area#pack () in let b3 = GButton.button ~label:"Show Label 3" ~packing:action_area#pack () in b1#connect#clicked ~callback:(fun () -> remove (); w := show 1); b2#connect#clicked ~callback:(fun () -> remove (); w := show 2); b3#connect#clicked ~callback:(fun () -> remove (); w := show 3); dialog#show (); GMain.main () ---------------------------------------------------------------------- -- Richard Jones. http://www.annexia.org/ http://freshmeat.net/users/rwmj Merjis Ltd. http://www.merjis.com/ - all your business data are belong to you. 'There is a joke about American engineers and French engineers. The American team brings a prototype to the French team. The French team's response is: "Well, it works fine in practice; but how will it hold up in theory?"'