Rearrange FrameMain deinitialization so that things which depend on the project context are guaranteed to be destroyed before the context

Originally committed to SVN as r5531.
This commit is contained in:
Thomas Goyne 2011-07-29 23:16:46 +00:00
parent 65368c5f35
commit ef26170214
2 changed files with 12 additions and 7 deletions

View file

@ -64,7 +64,6 @@
#include "compat.h" #include "compat.h"
#include "command/command.h" #include "command/command.h"
#include "dialog_search_replace.h" #include "dialog_search_replace.h"
#include "dialog_styling_assistant.h"
#include "dialog_version_check.h" #include "dialog_version_check.h"
#include "drop.h" #include "drop.h"
#include "help_button.h" #include "help_button.h"
@ -222,19 +221,26 @@ FrameMain::FrameMain (wxArrayString args)
} }
FrameMain::~FrameMain () { FrameMain::~FrameMain () {
// Because the subs grid is the selection controller, it needs to stay
// alive significantly longer than the other child controls
SubsGrid->Reparent(0);
SubsGrid->Hide();
context->videoController->SetVideo(""); context->videoController->SetVideo("");
context->audioController->CloseAudio(); context->audioController->CloseAudio();
if (context->stylingAssistant) context->stylingAssistant->Destroy();
SubsGrid->ClearMaps(); // Ensure the children get destroyed before the project context is destroyed
delete audioBox; DestroyChildren();
delete EditBox; wxTheApp->ProcessPendingEvents();
delete videoBox;
delete context->ass; delete context->ass;
HelpButton::ClearPages(); HelpButton::ClearPages();
delete context->audioController; delete context->audioController;
#ifdef WITH_AUTOMATION #ifdef WITH_AUTOMATION
delete context->local_scripts; delete context->local_scripts;
#endif #endif
SubsGrid->Destroy();
} }
void FrameMain::cmd_call(wxCommandEvent& event) { void FrameMain::cmd_call(wxCommandEvent& event) {

View file

@ -93,7 +93,6 @@ SubtitlesGrid::SubtitlesGrid(wxWindow *parent, agi::Context *context, const wxS
/// @brief Destructor /// @brief Destructor
SubtitlesGrid::~SubtitlesGrid() { SubtitlesGrid::~SubtitlesGrid() {
ClearMaps();
} }
void SubtitlesGrid::OnSubtitlesCommit(int type) { void SubtitlesGrid::OnSubtitlesCommit(int type) {