diff --git a/aegisub/src/frame_main.cpp b/aegisub/src/frame_main.cpp index 878bd0b75..c577da6d7 100644 --- a/aegisub/src/frame_main.cpp +++ b/aegisub/src/frame_main.cpp @@ -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) { diff --git a/aegisub/src/subs_grid.cpp b/aegisub/src/subs_grid.cpp index 376278ea2..c7689ed17 100644 --- a/aegisub/src/subs_grid.cpp +++ b/aegisub/src/subs_grid.cpp @@ -93,7 +93,6 @@ SubtitlesGrid::SubtitlesGrid(wxWindow *parent, agi::Context *context, const wxS /// @brief Destructor SubtitlesGrid::~SubtitlesGrid() { - ClearMaps(); } void SubtitlesGrid::OnSubtitlesCommit(int type) {