FIX: crash on MacOS when system logout, not really Close mainframe

Change-Id: I0e7cc73c1b4bbc663105034e82dcd7a51998e244
This commit is contained in:
chunmao.guo 2022-08-30 10:57:12 +08:00 committed by Lane.Wei
parent 8319ef604c
commit de712b08f1
3 changed files with 14 additions and 5 deletions

View File

@ -1836,7 +1836,16 @@ bool GUI_App::on_init_inner()
CBaseException::set_log_folder(data_dir());
#endif
wxGetApp().Bind(wxEVT_QUERY_END_SESSION, [](auto & e) {
wxGetApp().Bind(wxEVT_QUERY_END_SESSION, [this](auto & e) {
if (mainframe) {
wxCloseEvent e2(wxEVT_CLOSE_WINDOW);
e2.SetCanVeto(true);
mainframe->GetEventHandler()->ProcessEvent(e2);
if (e2.GetVeto()) {
e.Veto();
return;
}
}
for (auto d : dialogStack)
d->EndModal(1);
});

View File

@ -469,7 +469,7 @@ bool generate_image(const std::string &filename, wxImage &image, wxSize img_size
return true;
}
std::vector<wxDialog*> dialogStack;
std::deque<wxDialog*> dialogStack;
}
}

View File

@ -104,7 +104,7 @@ struct DpiChangedEvent : public wxEvent {
wxDECLARE_EVENT(EVT_DPI_CHANGED_SLICER, DpiChangedEvent);
#endif // !wxVERSION_EQUAL_OR_GREATER_THAN
extern std::vector<wxDialog*> dialogStack;
extern std::deque<wxDialog*> dialogStack;
template<class P> class DPIAware : public P
{
@ -226,9 +226,9 @@ public:
int ShowModal()
{
dialogStack.push_back(this);
dialogStack.push_front(this);
int r = wxDialog::ShowModal();
dialogStack.pop_back();
dialogStack.pop_front();
return r;
}