X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=matita%2FmatitaGui.ml;h=19251f0744b4467e32f403a38b7b747986959f83;hb=cd3f7fdf54fa106c58004f1ab8d7c1ecfc06aec0;hp=85d72ebe080b139f13778c62df915a8744829111;hpb=aa0d55d15c7450f43797e15538ea029e19792e07;p=helm.git diff --git a/matita/matitaGui.ml b/matita/matitaGui.ml index 85d72ebe0..19251f074 100644 --- a/matita/matitaGui.ml +++ b/matita/matitaGui.ml @@ -415,19 +415,58 @@ class gui () = let lock_world _ = main#buttonsToolbar#misc#set_sensitive false; develList#buttonsHbox#misc#set_sensitive false; + main#scriptMenu#misc#set_sensitive false; source_view#set_editable false in let unlock_world _ = main#buttonsToolbar#misc#set_sensitive true; develList#buttonsHbox#misc#set_sensitive true; - source_view#set_editable true + main#scriptMenu#misc#set_sensitive true; + source_view#set_editable true; + (*The next line seems sufficient to avoid some unknown race condition *) + GtkThread.sync (fun () -> ()) () in let worker_thread = ref None in + let notify_exn exn = + let floc, msg = MatitaExcPp.to_string exn in + begin + match floc with + None -> () + | Some floc -> + let (x, y) = HExtlib.loc_of_floc floc in + let script = MatitaScript.current () in + let locked_mark = script#locked_mark in + let error_tag = script#error_tag in + let baseoffset = + (source_buffer#get_iter_at_mark (`MARK locked_mark))#offset in + let x' = baseoffset + x in + let y' = baseoffset + y in + let x_iter = source_buffer#get_iter (`OFFSET x') in + let y_iter = source_buffer#get_iter (`OFFSET y') in + source_buffer#apply_tag error_tag ~start:x_iter ~stop:y_iter; + let id = ref None in + id := Some (source_buffer#connect#changed ~callback:(fun () -> + source_buffer#remove_tag error_tag + ~start:source_buffer#start_iter + ~stop:source_buffer#end_iter; + match !id with + | None -> assert false (* a race condition occurred *) + | Some id -> + (new GObj.gobject_ops source_buffer#as_buffer)#disconnect id)); + source_buffer#place_cursor + (source_buffer#get_iter (`OFFSET x')); + end; + HLog.error msg in let locker f () = let thread_main = fun () -> lock_world (); - try f ();unlock_world () with exc -> unlock_world (); raise exc + try + f (); + unlock_world () + with exc -> + notify_exn exc; + unlock_world () in worker_thread := Some (Thread.create thread_main ()) in let kill_worker = @@ -666,35 +705,7 @@ class gui () = | MatitaScript.ActionCancelled s -> HLog.error s | exn -> if not (Helm_registry.get_bool "matita.debug") then - let floc, msg = MatitaExcPp.to_string exn in - begin - match floc with - None -> () - | Some floc -> - let (x, y) = HExtlib.loc_of_floc floc in - let script = MatitaScript.current () in - let locked_mark = script#locked_mark in - let error_tag = script#error_tag in - let baseoffset = - (source_buffer#get_iter_at_mark (`MARK locked_mark))#offset in - let x' = baseoffset + x in - let y' = baseoffset + y in - let x_iter = source_buffer#get_iter (`OFFSET x') in - let y_iter = source_buffer#get_iter (`OFFSET y') in - source_buffer#apply_tag error_tag ~start:x_iter ~stop:y_iter; - let id = ref None in - id := Some (source_buffer#connect#changed ~callback:(fun () -> - source_buffer#remove_tag error_tag - ~start:source_buffer#start_iter - ~stop:source_buffer#end_iter; - match !id with - | None -> assert false (* a race condition occurred *) - | Some id -> - (new GObj.gobject_ops source_buffer#as_buffer)#disconnect id)); - source_buffer#place_cursor - (source_buffer#get_iter (`OFFSET x')); - end; - HLog.error msg + notify_exn exn else raise exn); (* script *) ignore (source_buffer#connect#mark_set (fun _ _ -> next_ligatures <- []));