Delivered-To: garrigue at math.nagoya-u.ac.jp Delivered-To: lablgtk at yquem.inria.fr Message-ID: <49257DF6.7080401 at comlab.ox.ac.uk> Date: Thu, 20 Nov 2008 15:10:46 +0000 From: Mike Spivey MIME-Version: 1.0 To: lablgtk at yquem.inria.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Subject: [Lablgtk] Problem with markers in sourceview This test program allows markers to be set on lines in a GSourceView widget by clicking in the left margin. On my setup (OCaml 3.10.2-3, Lablgtk 2.10.1-2, Ubuntu Intrepid), GTK shows critical errors after I click a couple of times. (bug:12461): GLib-GObject-CRITICAL **: g_object_unref: assertion `G_IS_OBJECT (object)' failed I've deliberately made the program turn over lots of memory; without the added code, it takes thirty clicks or so before the same message appears. What am I doing wrong? -- Mike let _ = GMain.init () let gensym = ref 0 let source_click (view : GSourceView.source_view) ev = if GdkEvent.get_type ev = `BUTTON_PRESS && view#get_window_type (GdkEvent.get_window ev) = `LEFT then begin let (x, y) = view#window_to_buffer_coords `LEFT (truncate (GdkEvent.Button.x ev)) (truncate (GdkEvent.Button.y ev)) in let (iter, _) = view#get_line_at_y y in let buf = view#source_buffer in let marks = List.filter (fun mk -> mk#get_type = "breakpoint") (buf#get_markers_in_region iter iter) in if marks <> [] then buf#delete_marker (List.hd marks) else begin incr gensym; ignore (buf#create_marker ~name:(string_of_int !gensym) ~typ:"breakpoint" iter); end end; (* Create lots of garbage *) let rec loop n xs = if n = 0 then () else loop (n-1) (n::xs) in loop 1000000 []; (* Swallow the event *) true let main () = let win = GWindow.window ~width:100 ~height:100 () in let buf = GSourceView.source_buffer ~text:"1\n2\n3\n" () in let view = GSourceView.source_view ~source_buffer:buf ~show_line_markers:true ~packing:win#add () in view#set_marker_pixbuf "breakpoint" (GdkPixbuf.from_file "/usr/share/pixmaps/apple-red.png"); ignore (view#event#connect#button_press (source_click view)); win#show (); GMain.main () let _ = main () _______________________________________________ Lablgtk mailing list Lablgtk@yquem.inria.fr http://yquem.inria.fr/cgi-bin/mailman/listinfo/lablgtk