Skip to content
Snippets Groups Projects
Commit 6467d01f authored by Allan Blanchard's avatar Allan Blanchard
Browse files

Merge branch 'fix/gui/toplevel-plugin-abort' into 'stable/cobalt'

[gui] Fixes GUI freeze when a plugin aborts after parsing succeeded.

See merge request frama-c/frama-c!4223
parents 40d7e256 3db90101
No related branches found
No related tags found
No related merge requests found
...@@ -1891,27 +1891,26 @@ let toplevel play = ...@@ -1891,27 +1891,26 @@ let toplevel play =
let error_manager = let error_manager =
new Gtk_helper.error_manager (splash_w:>GWindow.window_skel) new Gtk_helper.error_manager (splash_w:>GWindow.window_skel)
in in
let init_crashed = ref true in let init_crash = ref None in
error_manager#protect error_manager#protect
~cancelable:true ~parent:(splash_w:>GWindow.window_skel) ~cancelable:true ~parent:(splash_w:>GWindow.window_skel)
(fun () -> (fun () ->
(try try
play (); play ();
(* This is a good point to start using real asynchronous tasks (* This is a good point to start using real asynchronous tasks
management: plug-ins launched from command line have finished management: plug-ins launched from command line have finished
their asynchronous tasks thanks to the default Task.on_idle. *) their asynchronous tasks thanks to the default Task.on_idle. *)
Task.on_idle := Task.on_idle :=
(fun f -> ignore (Glib.Timeout.add ~ms:50 ~callback:f)); (fun f -> ignore (Glib.Timeout.add ~ms:50 ~callback:f));
let project_name = Gui_parameters.Project_name.get () in let project_name = Gui_parameters.Project_name.get () in
if project_name = "" then if project_name = "" then
Project.set_current_as_last_created () Project.set_current_as_last_created ()
else else
Project.set_current (Project.from_unique_name project_name); Project.set_current (Project.from_unique_name project_name);
Ast.compute () Ast.compute ()
with e -> (* An error occurred: we need to enforce the splash screen with e -> (* An error occurred: we need to enforce the splash screen
realization before we create the error dialog widget.*) realization before we create the error dialog widget.*)
force_s (); raise e); force_s (); init_crash := Some e; raise e);
init_crashed := false);
if Ast.is_computed () then if Ast.is_computed () then
(* if the ast has parsed, but a plugin has crashed, we display the gui *) (* if the ast has parsed, but a plugin has crashed, we display the gui *)
error_manager#protect ~cancelable:false error_manager#protect ~cancelable:false
...@@ -1921,18 +1920,18 @@ let toplevel play = ...@@ -1921,18 +1920,18 @@ let toplevel play =
Glib.Timeout.remove tid; Glib.Timeout.remove tid;
reparent_console main_ui#lower_notebook; reparent_console main_ui#lower_notebook;
splash_w#destroy (); splash_w#destroy ();
(* Display the console if a crash has occurred. Otherwise, display (* Display the console and an error dialog if a crash has occurred.
the information panel *) Otherwise, display the information panel. *)
if !init_crashed then match !init_crash with
(main_ui#lower_notebook#goto_page 2; | None -> main_ui#lower_notebook#goto_page 0
(* BY TODO: this should scroll to the end of the console. It | Some e ->
does not work at all after the reparent, and only partially main_ui#lower_notebook#goto_page 2;
before (scrollbar is wrong) *) (* BY TODO: this should scroll to the end of the console. It
let end_console = splash_out#buffer#end_iter in does not work at all after the reparent, and only partially
ignore (splash_out#scroll_to_iter ~yalign:0. end_console) before (scrollbar is wrong) *)
) let end_console = splash_out#buffer#end_iter in
else ignore (splash_out#scroll_to_iter ~yalign:0. end_console);
main_ui#lower_notebook#goto_page 0 error_manager#error ~reset:true "%s" (Cmdline.protect e);
) )
in in
ignore (Glib.Idle.add (fun () -> in_idle (); false)); ignore (Glib.Idle.add (fun () -> in_idle (); false));
......
...@@ -738,6 +738,7 @@ class error_manager ?reset (o_parent:GWindow.window_skel) : host = ...@@ -738,6 +738,7 @@ class error_manager ?reset (o_parent:GWindow.window_skel) : host =
~title:"Error" ~title:"Error"
~position:`CENTER_ALWAYS ~position:`CENTER_ALWAYS
~modal:true ~modal:true
~destroy_with_parent:true
() ()
in in
ignore (w#connect#response ~callback:(fun _ -> w#destroy ())); ignore (w#connect#response ~callback:(fun _ -> w#destroy ()));
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment