Applied patch [ 858324 ] Calling EndModal inside an EVT_INIT_DIALOG event handler
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@25126 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -114,7 +114,8 @@ protected:
|
|||||||
void Init();
|
void Init();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
wxWindow *m_oldFocus;
|
wxWindow* m_oldFocus;
|
||||||
|
bool m_endModalCalled; // allow for closing within InitDialog
|
||||||
|
|
||||||
// this pointer is non-NULL only while the modal event loop is running
|
// this pointer is non-NULL only while the modal event loop is running
|
||||||
wxDialogModalData *m_modalData;
|
wxDialogModalData *m_modalData;
|
||||||
|
@@ -170,11 +170,10 @@ wxDEFINE_TIED_SCOPED_PTR_TYPE(wxDialogModalData);
|
|||||||
void wxDialog::Init()
|
void wxDialog::Init()
|
||||||
{
|
{
|
||||||
m_oldFocus = (wxWindow *)NULL;
|
m_oldFocus = (wxWindow *)NULL;
|
||||||
|
|
||||||
m_isShown = FALSE;
|
m_isShown = FALSE;
|
||||||
|
|
||||||
m_modalData = NULL;
|
m_modalData = NULL;
|
||||||
|
m_endModalCalled = FALSE;
|
||||||
|
|
||||||
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
|
SetBackgroundColour(wxSystemSettings::GetColour(wxSYS_COLOUR_3DFACE));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -369,7 +368,10 @@ bool wxDialog::Show(bool show)
|
|||||||
InitDialog();
|
InitDialog();
|
||||||
}
|
}
|
||||||
|
|
||||||
if ( show && IsModal() )
|
// EndModal may have been called from InitDialog handler,
|
||||||
|
// which would cause an infinite loop if we didn't take it
|
||||||
|
// into account
|
||||||
|
if ( show && IsModal() && !m_endModalCalled )
|
||||||
{
|
{
|
||||||
// modal dialog needs a parent window, so try to find one
|
// modal dialog needs a parent window, so try to find one
|
||||||
if ( !GetParent() )
|
if ( !GetParent() )
|
||||||
@@ -391,6 +393,7 @@ void wxDialog::Raise()
|
|||||||
// a special version for Show(TRUE) for modal dialogs which returns return code
|
// a special version for Show(TRUE) for modal dialogs which returns return code
|
||||||
int wxDialog::ShowModal()
|
int wxDialog::ShowModal()
|
||||||
{
|
{
|
||||||
|
m_endModalCalled = FALSE;
|
||||||
if ( !IsModal() )
|
if ( !IsModal() )
|
||||||
{
|
{
|
||||||
SetModal(TRUE);
|
SetModal(TRUE);
|
||||||
@@ -405,6 +408,7 @@ int wxDialog::ShowModal()
|
|||||||
// dialogs and should work for both of them
|
// dialogs and should work for both of them
|
||||||
void wxDialog::EndModal(int retCode)
|
void wxDialog::EndModal(int retCode)
|
||||||
{
|
{
|
||||||
|
m_endModalCalled = TRUE;
|
||||||
SetReturnCode(retCode);
|
SetReturnCode(retCode);
|
||||||
|
|
||||||
Show(FALSE);
|
Show(FALSE);
|
||||||
|
Reference in New Issue
Block a user