From 386cd1e43b470f077c212a247cfcd39e542fbc29 Mon Sep 17 00:00:00 2001 From: George Tasker Date: Fri, 4 Aug 2000 11:03:22 +0000 Subject: [PATCH] Fixed some crashing code in dialog cleanup in some exceptional cases Fixed memory leak Set return codes on the modal dialogs to avoid use of uninitialized values git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/branches/WX_2_2_BRANCH@7929 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775 --- samples/db/dbtest.cpp | 49 +++++++++++++++++++++++++------------------ 1 file changed, 29 insertions(+), 20 deletions(-) diff --git a/samples/db/dbtest.cpp b/samples/db/dbtest.cpp index b2224c066d..a2bdbfef7a 100644 --- a/samples/db/dbtest.cpp +++ b/samples/db/dbtest.cpp @@ -401,20 +401,20 @@ void DatabaseDemoFrame::BuildEditorDialog() pEditorDlg = NULL; pEditorDlg = new CeditorDlg(this); if (pEditorDlg) + { pEditorDlg->Initialize(); - else - { - wxMessageBox("Unable to create the editor dialog for some reason","Error...",wxOK | wxICON_EXCLAMATION); - DemoFrame->Close(); - } - - if (!pEditorDlg->initialized) - { - pEditorDlg->Close(); - pEditorDlg = NULL; - wxMessageBox("Unable to initialize the editor dialog for some reason","Error...",wxOK | wxICON_EXCLAMATION); - DemoFrame->Close(TRUE); - } + if (!pEditorDlg->initialized) + { + pEditorDlg->Close(); + delete pEditorDlg; + wxMessageBox("Unable to initialize the editor dialog for some reason","Error...",wxOK | wxICON_EXCLAMATION); + DemoFrame->Close(); + } + } else + { + wxMessageBox("Unable to create the editor dialog for some reason","Error...",wxOK | wxICON_EXCLAMATION); + DemoFrame->Close(); + } } // DatabaseDemoFrame::BuildEditorDialog() @@ -921,7 +921,7 @@ bool CeditorDlg::Initialize() { // Table does exist, or there was some problem opening it. Currently this should // never fail, except in the case of the table not exisiting or the current - // user has insufficent privileges to access the table + // user has insufficent privileges to access the table #if 0 // This code is experimenting with a new function that will hopefully be available @@ -1471,20 +1471,26 @@ void CparameterDlg::OnCloseWindow(wxCloseEvent& event) if (!saved) { bool Ok = (wxMessageBox("No changes have been saved.\n\nAre you sure you wish exit the parameter screen?","Confirm",wxYES_NO|wxICON_QUESTION) == wxYES); - + if (!Ok) { event.Veto(); return; } - + wxGetApp().params = savedParamSettings; } -// if (GetParent() != NULL) -// GetParent()->SetFocus(); - this->Destroy(); + if (GetParent() != NULL) + GetParent()->SetFocus(); + while (wxIsBusy()) + wxEndBusyCursor(); + + Show(FALSE); + SetReturnCode(0); // added so BoundsChecker would not report use of uninitialized variable + + this->Destroy(); } // CparameterDlg::OnCloseWindow() @@ -1641,6 +1647,8 @@ void CparameterDlg::FillDataSourceList() int i; for (i = 0; wxStrlen(p[i]); i++) pParamODBCSourceList->Append(p[i]); + + delete p; } // CparameterDlg::CparameterDlg::FillDataSourceList() @@ -2005,8 +2013,9 @@ void CqueryDlg::OnCloseWindow(wxCloseEvent& event) wxEndBusyCursor(); Show(FALSE); - this->Destroy(); + SetReturnCode(1); // added so BoundsChecker would not report use of uninitialized variable + this->Destroy(); } // CqueryDlg::OnCloseWindow()