From: dpage Date: Thu, 7 May 2009 19:54:29 +0000 (+0000) Subject: Re-jigger the close-down code so we're not doing anything with event handlers after... X-Git-Url: http://git.postgresql.org/gitweb/static/gitweb.js?a=commitdiff_plain;h=7d8c09ec334c670758ef2020ec4c04ce3170f6e2;p=users%2Fquan74%2Fpgadmin-import.git Re-jigger the close-down code so we're not doing anything with event handlers after they may potentially have been destroyed. [Ashesh Vashi] git-svn-id: svn://svn.pgadmin.org/trunk/pgadmin3@7856 a7884b65-44f6-0310-8a51-81a127f17b15 --- diff --git a/pgadmin/frm/frmQuery.cpp b/pgadmin/frm/frmQuery.cpp index 111c878a0..f75c543d3 100644 --- a/pgadmin/frm/frmQuery.cpp +++ b/pgadmin/frm/frmQuery.cpp @@ -487,34 +487,32 @@ frmQuery::~frmQuery() { closing = true; - sqlQuery->Disconnect(wxID_ANY, wxEVT_SET_FOCUS,wxFocusEventHandler(frmQuery::OnFocus)); - sqlResult->Disconnect(wxID_ANY, wxEVT_SET_FOCUS, wxFocusEventHandler(frmQuery::OnFocus)); - msgResult->Disconnect(wxID_ANY, wxEVT_SET_FOCUS, wxFocusEventHandler(frmQuery::OnFocus)); - msgHistory->Disconnect(wxID_ANY, wxEVT_SET_FOCUS, wxFocusEventHandler(frmQuery::OnFocus)); + // Save frmQuery Perspective + settings->Write(wxT("frmQuery/Perspective-") + VerFromRev(FRMQUERY_PERPSECTIVE_VER), manager.SavePerspective()); + + // Uninitialize wxAUIManager + manager.UnInit(); if(sqlNotebook) { delete sqlNotebook; - controller->nullView(); //to avoid bug on *nix when deleting controller + sqlNotebook = NULL; } if(controller) + { delete controller; + controller = NULL; + } if(model) + { delete model; + model = NULL; + } if(adjustSizesTimer) + { delete adjustSizesTimer; - - // Commented out in the original GQB patch - why? - // if(tablesBrowser) - // delete tablesBrowser; - - settings->Write(wxT("frmQuery/Perspective-") + VerFromRev(FRMQUERY_PERPSECTIVE_VER), manager.SavePerspective()); - manager.UnInit(); - - settings->SetExplainAnalyze(queryMenu->IsChecked(MNU_ANALYZE)); - settings->SetExplainVerbose(queryMenu->IsChecked(MNU_VERBOSE)); - - sqlResult->Abort(); // to make sure conn is unused + adjustSizesTimer = NULL; + } while (cbConnection->GetCount() > 1) { @@ -523,20 +521,23 @@ frmQuery::~frmQuery() } if (favourites) + { delete favourites; + favourites = NULL; + } if (pgsTimer) + { delete pgsTimer; + pgsTimer = NULL; + } if (pgScript) + { delete pgScript; + pgScript = NULL; + } - /* - * Keep these lines at the end of this function, to avoid generating events before - * it gets executed completely. - * - * To avoid a bug on *nix system. - */ if (mainForm) mainForm->RemoveFrame(this); } @@ -1386,6 +1387,8 @@ void frmQuery::OnClose(wxCloseEvent& event) return; } + closing = true; + // Reset the panes if (viewMenu->IsChecked(MNU_OUTPUTPANE)) manager.GetPane(wxT("outputPane")).Show(true); @@ -1395,7 +1398,20 @@ void frmQuery::OnClose(wxCloseEvent& event) Hide(); + sqlQuery->Disconnect(wxID_ANY, wxEVT_SET_FOCUS,wxFocusEventHandler(frmQuery::OnFocus)); + sqlResult->Disconnect(wxID_ANY, wxEVT_SET_FOCUS, wxFocusEventHandler(frmQuery::OnFocus)); + msgResult->Disconnect(wxID_ANY, wxEVT_SET_FOCUS, wxFocusEventHandler(frmQuery::OnFocus)); + msgHistory->Disconnect(wxID_ANY, wxEVT_SET_FOCUS, wxFocusEventHandler(frmQuery::OnFocus)); + + controller->nullView(); //to avoid bug on *nix when deleting controller + + settings->SetExplainAnalyze(queryMenu->IsChecked(MNU_ANALYZE)); + settings->SetExplainVerbose(queryMenu->IsChecked(MNU_VERBOSE)); + + sqlResult->Abort(); // to make sure conn is unused + Destroy(); + }