Commit b6175e0a authored by MARCHE Claude's avatar MARCHE Claude
Browse files

do not save unmodified sessions

parent f82ee030
...@@ -470,6 +470,8 @@ let (_:GtkSignal.id) = ...@@ -470,6 +470,8 @@ let (_:GtkSignal.id) =
let (_:GtkSignal.id) = let (_:GtkSignal.id) =
goals_view#connect#row_expanded ~callback:(row_expanded true) goals_view#connect#row_expanded ~callback:(row_expanded true)
let session_needs_saving = ref false
module M = Session_scheduler.Make module M = Session_scheduler.Make
(struct (struct
type key = GTree.row_reference type key = GTree.row_reference
...@@ -507,6 +509,7 @@ module M = Session_scheduler.Make ...@@ -507,6 +509,7 @@ module M = Session_scheduler.Make
"Running: " ^ (string_of_int r)^ " " ^ (fan (!c / 10))) "Running: " ^ (string_of_int r)^ " " ^ (fan (!c / 10)))
let notify any = let notify any =
session_needs_saving := true;
let row,exp = let row,exp =
match any with match any with
| S.Goal g -> | S.Goal g ->
...@@ -653,6 +656,7 @@ let env_session,sched = ...@@ -653,6 +656,7 @@ let env_session,sched =
in in
let sched = M.init gconfig.max_running_processes in let sched = M.init gconfig.max_running_processes in
dprintf debug "@]@\n[Info] Opening session: done@."; dprintf debug "@]@\n[Info] Opening session: done@.";
session_needs_saving := false;
ref env_session, sched ref env_session, sched
with e -> with e ->
eprintf "@[Error while opening session:@ %a@.@]" eprintf "@[Error while opening session:@ %a@.@]"
...@@ -673,6 +677,7 @@ let () = ...@@ -673,6 +677,7 @@ let () =
dprintf debug "[Info] file %s already in database@." fn dprintf debug "[Info] file %s already in database@." fn
else else
try try
dprintf debug "[Info] adding file %s in database@." fn;
ignore (M.add_file !env_session fn) ignore (M.add_file !env_session fn)
with e -> with e ->
eprintf "@[Error while reading file@ '%s':@ %a@.@]" fn eprintf "@[Error while reading file@ '%s':@ %a@.@]" fn
...@@ -840,8 +845,12 @@ let (_ : GMenu.image_menu_item) = ...@@ -840,8 +845,12 @@ let (_ : GMenu.image_menu_item) =
*) *)
let save_session () = let save_session () =
eprintf "[Info] saving session@."; if !session_needs_saving then begin
S.save_session !env_session.S.session eprintf "[Info] saving session@.";
S.save_session !env_session.S.session;
session_needs_saving := false;
end
let exit_function ?(destroy=false) () = let exit_function ?(destroy=false) () =
eprintf "[Info] saving IDE config file@."; eprintf "[Info] saving IDE config file@.";
...@@ -866,6 +875,7 @@ let exit_function ?(destroy=false) () = ...@@ -866,6 +875,7 @@ let exit_function ?(destroy=false) () =
"xmllint --noout --dtdvalid share/why3session.dtd essai.xml" in "xmllint --noout --dtdvalid share/why3session.dtd essai.xml" in
if ret = 0 then eprintf "DTD validation succeeded, good!@."; if ret = 0 then eprintf "DTD validation succeeded, good!@.";
*) *)
if not !session_needs_saving then GMain.quit () else
match (Gconfig.config ()).saving_policy with match (Gconfig.config ()).saving_policy with
| 0 -> save_session (); GMain.quit () | 0 -> save_session (); GMain.quit ()
| 1 -> GMain.quit () | 1 -> GMain.quit ()
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment