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 "command/command.h"
#include "dialog_search_replace.h"
#include "dialog_styling_assistant.h"
#include "dialog_version_check.h"
#include "drop.h"
#include "help_button.h"
@ -222,19 +221,26 @@ FrameMain::FrameMain (wxArrayString args)
}
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->audioController->CloseAudio();
if (context->stylingAssistant) context->stylingAssistant->Destroy();
SubsGrid->ClearMaps();
delete audioBox;
delete EditBox;
delete videoBox;
// Ensure the children get destroyed before the project context is destroyed
DestroyChildren();
wxTheApp->ProcessPendingEvents();
delete context->ass;
HelpButton::ClearPages();
delete context->audioController;
#ifdef WITH_AUTOMATION
delete context->local_scripts;
#endif
SubsGrid->Destroy();
}
void FrameMain::cmd_call(wxCommandEvent& event) {

View File

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