Skip to content
Snippets Groups Projects
Commit ffce09ac authored by Julien Signoles's avatar Julien Signoles
Browse files

[project] fix a rare but critical bug of Project.on leading to an incorrect...

[project] fix a rare but critical bug of Project.on leading to an incorrect restoration of the former project
parent 6876d9ff
No related branches found
No related tags found
No related merge requests found
...@@ -379,12 +379,12 @@ let on ?selection p f x = ...@@ -379,12 +379,12 @@ let on ?selection p f x =
if old_current == p then f x if old_current == p then f x
else else
let set p = set_current ~on:true ?selection p in let set p = set_current ~on:true ?selection p in
let set_to_old () = let rec set_to_old old =
if not !keep_current then if not !keep_current then
try try
(* if someone asks for keeping [p] as current during the execution of (* if someone asks for keeping [p] as current during the execution of
[f], do not restore [old_current] at the end. *) [f], do not restore [old_current] at the end. *)
set old_current set old
with Invalid_argument _ -> with Invalid_argument _ ->
(* the old current project has been remove: replace it by the previous (* the old current project has been remove: replace it by the previous
one, if any *) one, if any *)
...@@ -393,16 +393,16 @@ let on ?selection p f x = ...@@ -393,16 +393,16 @@ let on ?selection p f x =
old_current.unique_name old_current.unique_name
(current ()).unique_name (current ()).unique_name
else else
Q.move_at_top (Q.nth 1 projects) projects set_to_old (Q.nth 1 projects)
in in
let go () = let go () =
set p; set p;
let r = f x in let r = f x in
set_to_old (); set_to_old old_current;
r r
in in
if debug_atleast 1 then go () if debug_atleast 1 then go ()
else begin try go () with e -> set_to_old (); raise e end else begin try go () with e -> set_to_old old_current; raise e end
(* [set_current] must never be called internally. *) (* [set_current] must never be called internally. *)
module Hide_set_current = struct let set_current () = assert false end module Hide_set_current = struct let set_current () = assert false end
......
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