Date: Tue, 16 Sep 2003 11:31:37 +0100 To: lablgtk at kaba.or.jp Subject: Memory handling bug: cannot access fields in a combo box belonging to a dialog which has been destroyed Message-ID: <20030916103137.GA25181 at redhat.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline From: Richard Jones The following program demonstrates a bug (I think) in the memory handling of lablgtk2 (tested against lablgtk2-20030828 on Linux and Windows). The program creates a dialog containing a combo box, then destroys the dialog, and tries to retrieve the text from the combo box. This fails with the following Gtk error: Fatal error: exception Glib.Critical("GLib-GObject", "file gobject.c: line 1319 (g_object_ref): assertion `G_IS_OBJECT (object)' failed") and the program aborts. The entry widget in the combo box shouldn't, of course, be deleted until all references held by the program have been destroyed. Rich. ---------------------------------------------------------------------- (* Test reading strings from a combo box in a dialog which has been destroyed. * By Richard W.M. Jones * $Id: dialogdestroy.ml,v 1.1 2003/09/16 10:26:03 rich Exp $ * * Compile with: * ocamlopt -w s -I +lablgtk2 lablgtk.cmxa gtkInit.cmx dialogdestroy.ml \ * -o dialogdestroy *) let () = let dialog = GWindow.dialog () in dialog#connect#destroy ~callback:GMain.Main.quit; dialog#set_position `CENTER; let entry = GEdit.combo ~value_in_list:true ~allow_empty:false ~popdown_strings: ["option1"; "option2"; "option3"] ~packing:dialog#vbox#pack () in let ok_button = GButton.button ~label:"Test" ~packing:dialog#action_area#add () in ok_button#connect#clicked ~callback:dialog#destroy; dialog#show (); GMain.Main.main (); (* Dialog has been destroyed here. Try to get the text from the combo. *) let text = entry#entry#text in prerr_endline ("text is: " ^ text) ---------------------------------------------------------------------- -- 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. MAKE+ is a sane replacement for GNU autoconf/automake. One script compiles, RPMs, pkgs etc. Linux, BSD, Solaris. http://www.annexia.org/freeware/makeplus/