From 2454446233ef84bb660c2e02f06f17912b297304 Mon Sep 17 00:00:00 2001 From: daveluff Date: Mon, 20 Oct 2003 21:48:57 +0000 Subject: [PATCH] Fix a crash from the ATC Frequency dialog at the temporary expense of a small memory leak --- src/ATC/ATCDialog.cxx | 63 ++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 30 deletions(-) diff --git a/src/ATC/ATCDialog.cxx b/src/ATC/ATCDialog.cxx index 22e886f2e..0bb9ce5b2 100644 --- a/src/ATC/ATCDialog.cxx +++ b/src/ATC/ATCDialog.cxx @@ -413,31 +413,36 @@ void FGATCDialog::DoDialog() { // ////////////////////////////////////////////////////// -static puDialogBox* atcFreqDialog; -static puFrame* atcFreqDialogFrame; -static puText* atcFreqDialogMessage; -static puInput* atcFreqDialogInput; -static puOneShot* atcFreqDialogOkButton; -static puOneShot* atcFreqDialogCancelButton; -//static puButtonBox* atcFreqDialogCommunicationOptions; - -static puText* atcFreqDisplayText[20]; +static puDialogBox* atcFreqDialog; +static puFrame* atcFreqDialogFrame; +static puText* atcFreqDialogMessage; +static puInput* atcFreqDialogInput; +static puOneShot* atcFreqDialogOkButton; +static puOneShot* atcFreqDialogCancelButton; + +static puDialogBox* atcFreqDisplay; +static puFrame* atcFreqDisplayFrame; +static puText* atcFreqDisplayMessage; +static puOneShot* atcFreqDisplayOkButton; +static puOneShot* atcFreqDisplayCancelButton; +static puText* atcFreqDisplayText[20]; static void FreqDialogCancel(puObject*) { FG_POP_PUI_DIALOG(atcFreqDialog); - delete atcFreqDialog; } static void FreqDialogOK(puObject*) { string tmp = atcFreqDialogInput->getStringValue(); FG_POP_PUI_DIALOG(atcFreqDialog); - delete atcFreqDialog; current_atcdialog->FreqDisplay(tmp); } static void FreqDisplayOK(puObject*) { - FG_POP_PUI_DIALOG(atcFreqDialog); - delete atcFreqDialog; + FG_POP_PUI_DIALOG(atcFreqDisplay); +} + +static void FreqDisplayCancel(puObject*) { + FG_POP_PUI_DIALOG(atcFreqDisplay); } void FGATCDialog::FreqDialog() { @@ -471,8 +476,6 @@ void FGATCDialog::FreqDialog() { atcFreqDialogMessage -> setDefaultValue ("Enter airport identifier:"); atcFreqDialogMessage -> getDefaultValue (&s); atcFreqDialogMessage -> setLabel (s); - //atcFreqDialogMessage -> setLabelPlace (PUPLACE_TOP_CENTERED); - //atcFreqDialogMessage -> setLabelPlace (0); atcFreqDialogInput = new puInput (50, (hsize - 75), 150, (hsize - 45)); atcFreqDialogInput->acceptInput(); @@ -552,14 +555,14 @@ void FGATCDialog::FreqDisplay(string ident) { } int hsize = (n < 0 ? 100 : 105 + (n * 30)); - atcFreqDialog = new puDialogBox (250, 50); + atcFreqDisplay = new puDialogBox (250, 50); { - atcFreqDialogFrame = new puFrame (0, 0, 400, hsize); + atcFreqDisplayFrame = new puFrame (0, 0, 400, hsize); - atcFreqDialogMessage = new puText (40, (hsize - 30)); - atcFreqDialogMessage -> setDefaultValue (label.c_str()); - atcFreqDialogMessage -> getDefaultValue (&s); - atcFreqDialogMessage -> setLabel (s); + atcFreqDisplayMessage = new puText (40, (hsize - 30)); + atcFreqDisplayMessage -> setDefaultValue (label.c_str()); + atcFreqDisplayMessage -> getDefaultValue (&s); + atcFreqDisplayMessage -> setLabel (s); for(int i=0; i setLabel (s); } - atcFreqDialogOkButton = new puOneShot (50, 10, 110, 50); - atcFreqDialogOkButton -> setLegend (gui_msg_OK); - atcFreqDialogOkButton -> makeReturnDefault (TRUE); - atcFreqDialogOkButton -> setCallback (FreqDisplayOK); + atcFreqDisplayOkButton = new puOneShot (50, 10, 110, 50); + atcFreqDisplayOkButton -> setLegend (gui_msg_OK); + atcFreqDisplayOkButton -> makeReturnDefault (TRUE); + atcFreqDisplayOkButton -> setCallback (FreqDisplayOK); - atcFreqDialogCancelButton = new puOneShot (140, 10, 210, 50); - atcFreqDialogCancelButton -> setLegend (gui_msg_CANCEL); - atcFreqDialogCancelButton -> setCallback (FreqDialogCancel); + atcFreqDisplayCancelButton = new puOneShot (140, 10, 210, 50); + atcFreqDisplayCancelButton -> setLegend (gui_msg_CANCEL); + atcFreqDisplayCancelButton -> setCallback (FreqDisplayCancel); } - FG_FINALIZE_PUI_DIALOG(atcFreqDialog); + FG_FINALIZE_PUI_DIALOG(atcFreqDisplay); - FG_PUSH_PUI_DIALOG(atcFreqDialog); + FG_PUSH_PUI_DIALOG(atcFreqDisplay); } -- 2.39.5