X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/47d67540a017101b3e46abe9ef0f55914d8de37e..44c4a3348693414bace13852e50d926c1aa9f08b:/src/msw/dialog.cpp?ds=sidebyside diff --git a/src/msw/dialog.cpp b/src/msw/dialog.cpp index 85ba82edd0..bad108e769 100644 --- a/src/msw/dialog.cpp +++ b/src/msw/dialog.cpp @@ -78,7 +78,6 @@ wxDialog::wxDialog(void) m_modalShowing = FALSE; SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); - SetDefaultBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); } bool wxDialog::Create(wxWindow *parent, wxWindowID id, @@ -89,7 +88,6 @@ bool wxDialog::Create(wxWindow *parent, wxWindowID id, const wxString& name) { SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); - SetDefaultBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); SetName(name); if (!parent) @@ -311,7 +309,6 @@ bool wxDialog::Show(bool show) { m_hwndOldFocus = (WXHWND)::GetFocus(); - wxList DisabledWindows; if (m_modalShowing) { BringWindowToTop((HWND) GetHWND()); @@ -327,6 +324,13 @@ bool wxDialog::Show(bool show) ::EnableWindow((HWND) box->GetHWND(), FALSE); node = node->Next(); } + + // if we don't do it, some window might be deleted while we have pointers + // to them in our disabledWindows list and the program will crash when it + // will try to reenable them after the modal dialog end + wxTheApp->DeletePendingObjects(); + wxList disabledWindows; + node = wxModelessWindows.First(); while (node) { @@ -334,7 +338,7 @@ bool wxDialog::Show(bool show) if (::IsWindowEnabled((HWND) win->GetHWND())) { ::EnableWindow((HWND) win->GetHWND(), FALSE); - DisabledWindows.Append(win); + disabledWindows.Append(win); } node = node->Next(); } @@ -373,7 +377,7 @@ bool wxDialog::Show(bool show) } } // dfgg: now must specifically re-enable all other app windows that we disabled earlier - node=DisabledWindows.First(); + node=disabledWindows.First(); while(node) { wxWindow* win = (wxWindow*) node->Data(); HWND hWnd = (HWND) win->GetHWND(); @@ -523,8 +527,8 @@ void wxDialog::OnOK(wxCommandEvent& event) EndModal(wxID_OK); else { - SetReturnCode(wxID_OK); - this->Show(FALSE); + SetReturnCode(wxID_OK); + this->Show(FALSE); } } } @@ -549,7 +553,7 @@ void wxDialog::OnCancel(wxCommandEvent& event) bool wxDialog::OnClose(void) { - // Behaviour changed in 2.0: we'll send a Cancel message by default, + // Behaviour changed in 2.0: we'll send a Cancel message by default, // which may close the dialog. // Check for looping if the Cancel event handler calls Close() @@ -560,13 +564,13 @@ bool wxDialog::OnClose(void) closing.Append(this); - wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); - cancelEvent.SetEventObject( this ); - GetEventHandler()->ProcessEvent(cancelEvent); + wxCommandEvent cancelEvent(wxEVT_COMMAND_BUTTON_CLICKED, wxID_CANCEL); + cancelEvent.SetEventObject( this ); + GetEventHandler()->ProcessEvent(cancelEvent); closing.DeleteObject(this); - return FALSE; + return FALSE; } void wxDialog::OnCloseWindow(wxCloseEvent& event) @@ -576,6 +580,8 @@ void wxDialog::OnCloseWindow(wxCloseEvent& event) { this->Destroy(); } + else + event.Veto(TRUE); } // Destroy the window (delayed, if a managed window) @@ -592,7 +598,6 @@ void wxDialog::OnSysColourChanged(wxSysColourChangedEvent& event) Ctl3dColorChange(); #else SetBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); - SetDefaultBackgroundColour(wxSystemSettings::GetSystemColour(wxSYS_COLOUR_3DFACE)); Refresh(); #endif }