From 1f6033e151fd409bb78855ed33591244b741cbb3 Mon Sep 17 00:00:00 2001 From: Pascal Brisset Date: Mon, 13 Mar 2006 15:44:46 +0000 Subject: [PATCH] Catching the XML window savage destroy --- sw/ground_segment/cockpit/map2d.ml | 16 +++++++++------- sw/lib/ocaml/mapFP.ml | 2 +- sw/lib/ocaml/mapFP.mli | 2 +- 3 files changed, 11 insertions(+), 9 deletions(-) diff --git a/sw/ground_segment/cockpit/map2d.ml b/sw/ground_segment/cockpit/map2d.ml index 94b19fcddb..f8c03e5187 100644 --- a/sw/ground_segment/cockpit/map2d.ml +++ b/sw/ground_segment/cockpit/map2d.ml @@ -480,10 +480,18 @@ module Edit = struct | None -> f () + let close_fp = fun geomap () -> + match !current_fp with + None -> () (* Nothing to close *) + | Some (fp, filename) -> + fp#destroy (); + current_fp := None + let load_xml_fp = fun geomap ?(xml_file=path_fps) xml -> set_georef_if_none geomap (georef_of_fp xml); let fp = new MapFP.flight_plan geomap "red" fp_dtd xml in - fp#show_xml (); + fp#window#show (); + ignore (fp#window#connect#destroy ~callback:(close_fp geomap)); current_fp := Some (fp,xml_file); fp @@ -544,12 +552,6 @@ module Edit = struct | Some (fp,_) -> ignore (fp#add_waypoint geo) - let close_fp = fun geomap () -> - match !current_fp with - None -> () (* Nothing to close *) - | Some (fp, filename) -> - fp#destroy (); - current_fp := None let save_fp = fun geomap () -> match !current_fp with diff --git a/sw/lib/ocaml/mapFP.ml b/sw/lib/ocaml/mapFP.ml index 6f50664897..69cb382395 100644 --- a/sw/lib/ocaml/mapFP.ml +++ b/sw/lib/ocaml/mapFP.ml @@ -113,7 +113,7 @@ class flight_plan = fun geomap color fp_dtd xml -> object val mutable max_dist_from_home = max_dist_from_home method georef = ref_wgs84 - method show_xml () = xml_window#show () + method window = xml_window method destroy () = wpts_group#group#destroy (); xml_window#destroy () diff --git a/sw/lib/ocaml/mapFP.mli b/sw/lib/ocaml/mapFP.mli index 3ea707926a..de99063ca1 100644 --- a/sw/lib/ocaml/mapFP.mli +++ b/sw/lib/ocaml/mapFP.mli @@ -38,7 +38,7 @@ class flight_plan : method hide : unit -> unit method index : XmlEdit.node -> int * MapWaypoints.waypoint method show : unit -> unit - method show_xml : unit -> unit + method window : GWindow.window method waypoints : XmlEdit.node list method xml : Xml.xml end