diff --git a/Nasal/canvas/generic-canvas-map.xml b/Nasal/canvas/generic-canvas-map.xml index 01a6151ac..30ab91e48 100644 --- a/Nasal/canvas/generic-canvas-map.xml +++ b/Nasal/canvas/generic-canvas-map.xml @@ -97,8 +97,8 @@ In the close block, you'll want to call "map.cleanup_listeners()" at the moment .setupZoom( dialog:DIALOG_CANVAS ) # TODO: make zooming configurable for non GUI use .pickupFeatures (DIALOG_CANVAS); # set up the features specified in the XML file - # FIXME: resource cleanup (listeners!) - update_info(); + canvas.run_callbacks(); # WORKAROUND to run dialog-specific init code - + # must be set up via register_callback() in the dialog's open block currently ]]> diff --git a/Nasal/canvas/map.nas b/Nasal/canvas/map.nas index 768e6639a..aa144d27f 100644 --- a/Nasal/canvas/map.nas +++ b/Nasal/canvas/map.nas @@ -37,6 +37,12 @@ # +#FIXME: this is a hack so that dialogs can register their own +# callbacks that are automatically invoked at the end of the +# generic-canvas-map.xml file (canvas/nasal section) +var callbacks = []; +var register_callback = func(c) append(callbacks, c); +var run_callbacks = func foreach(var c; callbacks) c(); var DEBUG=0; if (DEBUG) { @@ -418,7 +424,7 @@ LayeredMap.updateState = func { #FIXME: listener management should be done at the MVC level, for each component - not as part of the LayeredMap! LayeredMap.cleanup_listeners = func { - print("Cleaning up listeners"); + # print("Cleaning up listeners"); foreach(var l; me.listeners) removelistener(l); diff --git a/gui/dialogs/airports.xml b/gui/dialogs/airports.xml index ba9454030..47749fc6d 100644 --- a/gui/dialogs/airports.xml +++ b/gui/dialogs/airports.xml @@ -190,14 +190,13 @@ } } - update_info(); - + canvas.register_callback(update_info); # FIXME: this is a workaround to run dialog-specific code in the canvas block ]]> fgcommand("clear-metar", var n = props.Node.new({ "path": "/sim/gui/dialogs/airports/selected-airport/metar", "station": airport_id})); - # map.cleanup_listeners(); #TODO: We should be setting a signal when closing the dialog, so that cleanup code can be invoked automatically + map.cleanup_listeners(); #TODO: We should be setting a signal when closing the dialog, so that cleanup code can be invoked automatically @@ -657,6 +656,7 @@ Show Tower enabled +