mirror of https://github.com/PCSX2/pcsx2.git
gui: Fix looping dialog event handling
The dialog event handling is a bit messed up. An ok/cancel event sends a close event, which sends a cancel event and repeats. This would actually be an infinite loop if wxWidgets didn't detect a loop. Rework the event handling to avoid the loop and to remember the positions of modal dialogs as well.
This commit is contained in:
parent
d9447de492
commit
2a4bd85f53
|
@ -512,11 +512,11 @@ public:
|
|||
void Init( const pxDialogCreationFlags& cflags );
|
||||
void AddOkCancel( wxSizer& sizer, bool hasApply=false );
|
||||
void AddOkCancel( wxSizer* sizer=NULL, bool hasApply=false );
|
||||
void RememberPosition();
|
||||
|
||||
virtual void SmartCenterFit();
|
||||
virtual int ShowModal();
|
||||
virtual bool Show( bool show=true );
|
||||
virtual bool Destroy();
|
||||
|
||||
// Must return the same thing as GetNameStatic; a name ideal for use in uniquely
|
||||
// identifying dialogs. (this version is the 'instance' version, which is called
|
||||
|
@ -536,7 +536,6 @@ public:
|
|||
protected:
|
||||
void OnDialogCreated( wxCommandEvent& evt );
|
||||
void OnOkCancel(wxCommandEvent& evt);
|
||||
void OnCloseWindow(wxCloseEvent& event);
|
||||
|
||||
bool ShouldPreventAppExit() const { return false; }
|
||||
|
||||
|
|
|
@ -171,7 +171,6 @@ void wxDialogWithHelpers::Init( const pxDialogCreationFlags& cflags )
|
|||
|
||||
Connect( wxID_OK, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (wxDialogWithHelpers::OnOkCancel) );
|
||||
Connect( wxID_CANCEL, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler (wxDialogWithHelpers::OnOkCancel) );
|
||||
Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler (wxDialogWithHelpers::OnCloseWindow) );
|
||||
|
||||
wxCommandEvent createEvent( pxEvt_OnDialogCreated );
|
||||
createEvent.SetId( GetId() );
|
||||
|
@ -287,7 +286,7 @@ pxStaticText& wxDialogWithHelpers::Heading( const wxString& label )
|
|||
return *new pxStaticHeading( this, label );
|
||||
}
|
||||
|
||||
bool wxDialogWithHelpers::Destroy()
|
||||
void wxDialogWithHelpers::RememberPosition()
|
||||
{
|
||||
// Save the dialog position if the dialog is named...
|
||||
// FIXME : This doesn't get called if the app is exited by alt-f4'ing the main app window.
|
||||
|
@ -312,20 +311,18 @@ bool wxDialogWithHelpers::Destroy()
|
|||
saver.Entry( dlgName + L"_Pos", pos, screenRect.GetPosition() );
|
||||
}
|
||||
}
|
||||
|
||||
return _parent::Destroy();
|
||||
}
|
||||
|
||||
void wxDialogWithHelpers::OnCloseWindow( wxCloseEvent& evt )
|
||||
{
|
||||
if( !IsModal() ) Destroy();
|
||||
evt.Skip();
|
||||
}
|
||||
|
||||
void wxDialogWithHelpers::OnOkCancel( wxCommandEvent& evt )
|
||||
{
|
||||
Close();
|
||||
evt.Skip();
|
||||
RememberPosition();
|
||||
|
||||
// Modal dialogs should be destroyed after ShowModal returns, otherwise there
|
||||
// might be double delete problems if the dialog was declared on the stack.
|
||||
if (!IsModal())
|
||||
Destroy();
|
||||
else
|
||||
evt.Skip();
|
||||
}
|
||||
|
||||
void wxDialogWithHelpers::AddOkCancel( wxSizer &sizer, bool hasApply )
|
||||
|
|
|
@ -144,8 +144,6 @@ Dialogs::BaseConfigurationDialog::BaseConfigurationDialog( wxWindow* parent, con
|
|||
Connect( wxID_APPLY, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BaseConfigurationDialog::OnApply_Click ) );
|
||||
Connect( wxID_SAVE, wxEVT_COMMAND_BUTTON_CLICKED, wxCommandEventHandler( BaseConfigurationDialog::OnScreenshot_Click ) );
|
||||
|
||||
Connect( wxEVT_CLOSE_WINDOW, wxCloseEventHandler(BaseConfigurationDialog::OnCloseWindow) );
|
||||
|
||||
Connect( pxEvt_SetSettingsPage, wxCommandEventHandler( BaseConfigurationDialog::OnSetSettingsPage ) );
|
||||
|
||||
// ----------------------------------------------------------------------------
|
||||
|
@ -230,14 +228,6 @@ void Dialogs::BaseConfigurationDialog::OnSomethingChanged( wxCommandEvent& evt )
|
|||
SomethingChanged();
|
||||
}
|
||||
|
||||
|
||||
void Dialogs::BaseConfigurationDialog::OnCloseWindow( wxCloseEvent& evt )
|
||||
{
|
||||
if( !IsModal() ) Destroy();
|
||||
evt.Skip();
|
||||
}
|
||||
|
||||
|
||||
void Dialogs::BaseConfigurationDialog::AllowApplyActivation( bool allow )
|
||||
{
|
||||
m_allowApplyActivation = allow;
|
||||
|
@ -280,7 +270,6 @@ void Dialogs::BaseConfigurationDialog::OnApply_Click( wxCommandEvent& evt )
|
|||
SomethingChanged_StateModified_IsChanged();
|
||||
}
|
||||
|
||||
//avih: FIXME: ? for some reason, this OnCancel_Click is called twice when clicking cancel or closing the dialog (Jake's code?).
|
||||
void Dialogs::BaseConfigurationDialog::OnCancel_Click( wxCommandEvent& evt )
|
||||
{
|
||||
//same as for Ok/Apply: let SysConfigDialog clean-up the presets and derivatives (menu system) if needed.
|
||||
|
|
|
@ -76,7 +76,6 @@ namespace Dialogs
|
|||
void OnCancel_Click( wxCommandEvent& evt );
|
||||
void OnApply_Click( wxCommandEvent& evt );
|
||||
void OnScreenshot_Click( wxCommandEvent& evt );
|
||||
void OnCloseWindow( wxCloseEvent& evt );
|
||||
|
||||
void OnSetSettingsPage( wxCommandEvent& evt );
|
||||
void OnSomethingChanged( wxCommandEvent& evt );
|
||||
|
|
Loading…
Reference in New Issue