mirror of https://github.com/PCSX2/pcsx2.git
pcsx2: Make memory card dialog modal
There were bugs in the UI handling that allowed you to resume emulation when the memory card dialog was opened, which could potentially cause data loss/corruption. Make the memory card dialog modal to prevent this. Although it's possible to do with a modeless dialog, the solution will be much more complicated and less future proof. This also fixes the emulation resume bug after closing the memory card dialog.
This commit is contained in:
parent
c17eacec04
commit
1cbae66bb3
|
@ -155,7 +155,6 @@ namespace Dialogs
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
Panels::BaseMcdListPanel* m_panel_mcdlist;
|
Panels::BaseMcdListPanel* m_panel_mcdlist;
|
||||||
bool m_needs_suspending;
|
|
||||||
|
|
||||||
public:
|
public:
|
||||||
virtual ~McdConfigDialog() throw() {}
|
virtual ~McdConfigDialog() throw() {}
|
||||||
|
@ -163,9 +162,6 @@ namespace Dialogs
|
||||||
static wxString GetNameStatic() { return L"McdConfig"; }
|
static wxString GetNameStatic() { return L"McdConfig"; }
|
||||||
wxString GetDialogName() const { return GetNameStatic(); }
|
wxString GetDialogName() const { return GetNameStatic(); }
|
||||||
|
|
||||||
virtual bool Show( bool show=true );
|
|
||||||
virtual int ShowModal();
|
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
virtual wxString& GetConfSettingsTabName() const { return g_Conf->McdSettingsTabName; }
|
virtual wxString& GetConfSettingsTabName() const { return g_Conf->McdSettingsTabName; }
|
||||||
//void OnMultitapClicked( wxCommandEvent& evt );
|
//void OnMultitapClicked( wxCommandEvent& evt );
|
||||||
|
|
|
@ -101,7 +101,6 @@ Dialogs::McdConfigDialog::McdConfigDialog( wxWindow* parent )
|
||||||
: BaseConfigurationDialog( parent, _("MemoryCard Manager"), 600 )
|
: BaseConfigurationDialog( parent, _("MemoryCard Manager"), 600 )
|
||||||
{
|
{
|
||||||
m_panel_mcdlist = new MemoryCardListPanel_Simple( this );
|
m_panel_mcdlist = new MemoryCardListPanel_Simple( this );
|
||||||
m_needs_suspending = false;
|
|
||||||
|
|
||||||
wxFlexGridSizer* s_flex=new wxFlexGridSizer(3,1, 0, 0);
|
wxFlexGridSizer* s_flex=new wxFlexGridSizer(3,1, 0, 0);
|
||||||
s_flex->AddGrowableCol(0);
|
s_flex->AddGrowableCol(0);
|
||||||
|
@ -152,30 +151,3 @@ void Dialogs::McdConfigDialog::OnMultitapClicked( wxCommandEvent& evt )
|
||||||
m_panel_mcdlist->SetMultitapEnabled( (int)box->GetClientData(), box->IsChecked() );
|
m_panel_mcdlist->SetMultitapEnabled( (int)box->GetClientData(), box->IsChecked() );
|
||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
bool Dialogs::McdConfigDialog::Show( bool show )
|
|
||||||
{
|
|
||||||
// Suspend the emulation before any file operations on the memory cards can be done.
|
|
||||||
if( show && CoreThread.IsRunning() )
|
|
||||||
{
|
|
||||||
m_needs_suspending = true;
|
|
||||||
CoreThread.Suspend();
|
|
||||||
}
|
|
||||||
else if( !show && m_needs_suspending == true )
|
|
||||||
{
|
|
||||||
m_needs_suspending = false;
|
|
||||||
CoreThread.Resume();
|
|
||||||
}
|
|
||||||
|
|
||||||
if( show && m_panel_mcdlist )
|
|
||||||
m_panel_mcdlist->OnShown();
|
|
||||||
|
|
||||||
return _parent::Show( show );
|
|
||||||
}
|
|
||||||
|
|
||||||
int Dialogs::McdConfigDialog::ShowModal()
|
|
||||||
{
|
|
||||||
if( m_panel_mcdlist )
|
|
||||||
m_panel_mcdlist->OnShown();
|
|
||||||
|
|
||||||
return _parent::ShowModal();
|
|
||||||
}
|
|
||||||
|
|
|
@ -15,6 +15,7 @@
|
||||||
|
|
||||||
#include "PrecompiledHeader.h"
|
#include "PrecompiledHeader.h"
|
||||||
|
|
||||||
|
#include "App.h"
|
||||||
#include "CDVD/CDVD.h"
|
#include "CDVD/CDVD.h"
|
||||||
#include "GS.h"
|
#include "GS.h"
|
||||||
|
|
||||||
|
@ -37,7 +38,9 @@ void MainEmuFrame::Menu_SysSettings_Click(wxCommandEvent &event)
|
||||||
|
|
||||||
void MainEmuFrame::Menu_McdSettings_Click(wxCommandEvent &event)
|
void MainEmuFrame::Menu_McdSettings_Click(wxCommandEvent &event)
|
||||||
{
|
{
|
||||||
AppOpenDialog<McdConfigDialog>( this );
|
ScopedCoreThreadClose closed_core;
|
||||||
|
closed_core.AllowResume();
|
||||||
|
AppOpenModalDialog<McdConfigDialog>(wxEmptyString, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
void MainEmuFrame::Menu_GameDatabase_Click(wxCommandEvent &event)
|
void MainEmuFrame::Menu_GameDatabase_Click(wxCommandEvent &event)
|
||||||
|
|
|
@ -618,9 +618,6 @@ void Panels::MemoryCardListPanel_Simple::Apply()
|
||||||
{
|
{
|
||||||
_parent::Apply();
|
_parent::Apply();
|
||||||
|
|
||||||
ScopedCoreThreadClose closed_core;
|
|
||||||
closed_core.AllowResume();
|
|
||||||
|
|
||||||
int used=0;
|
int used=0;
|
||||||
Console.WriteLn( L"Apply Memory cards:" );
|
Console.WriteLn( L"Apply Memory cards:" );
|
||||||
for( uint slot=0; slot<8; ++slot )
|
for( uint slot=0; slot<8; ++slot )
|
||||||
|
@ -736,8 +733,6 @@ void Panels::MemoryCardListPanel_Simple::UiCreateNewCard( McdSlotItem& card )
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopedCoreThreadClose closed_core;
|
|
||||||
|
|
||||||
Dialogs::CreateMemoryCardDialog dialog( this, m_FolderPicker->GetPath(), L"my memory card" );
|
Dialogs::CreateMemoryCardDialog dialog( this, m_FolderPicker->GetPath(), L"my memory card" );
|
||||||
wxWindowID result = dialog.ShowModal();
|
wxWindowID result = dialog.ShowModal();
|
||||||
|
|
||||||
|
@ -756,7 +751,6 @@ void Panels::MemoryCardListPanel_Simple::UiCreateNewCard( McdSlotItem& card )
|
||||||
|
|
||||||
Apply();
|
Apply();
|
||||||
RefreshSelections();
|
RefreshSelections();
|
||||||
closed_core.AllowResume();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Panels::MemoryCardListPanel_Simple::UiConvertCard( McdSlotItem& card ) {
|
void Panels::MemoryCardListPanel_Simple::UiConvertCard( McdSlotItem& card ) {
|
||||||
|
@ -765,8 +759,6 @@ void Panels::MemoryCardListPanel_Simple::UiConvertCard( McdSlotItem& card ) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopedCoreThreadClose closed_core;
|
|
||||||
|
|
||||||
AppConfig::McdOptions config;
|
AppConfig::McdOptions config;
|
||||||
config.Filename = card.Filename.GetFullName();
|
config.Filename = card.Filename.GetFullName();
|
||||||
config.Enabled = card.IsEnabled;
|
config.Enabled = card.IsEnabled;
|
||||||
|
@ -778,8 +770,6 @@ void Panels::MemoryCardListPanel_Simple::UiConvertCard( McdSlotItem& card ) {
|
||||||
Apply();
|
Apply();
|
||||||
RefreshSelections();
|
RefreshSelections();
|
||||||
}
|
}
|
||||||
|
|
||||||
closed_core.AllowResume();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Panels::MemoryCardListPanel_Simple::UiDeleteCard( McdSlotItem& card )
|
void Panels::MemoryCardListPanel_Simple::UiDeleteCard( McdSlotItem& card )
|
||||||
|
@ -804,7 +794,6 @@ void Panels::MemoryCardListPanel_Simple::UiDeleteCard( McdSlotItem& card )
|
||||||
|
|
||||||
if( result )
|
if( result )
|
||||||
{
|
{
|
||||||
ScopedCoreThreadClose closed_core;
|
|
||||||
|
|
||||||
wxFileName fullpath( m_FolderPicker->GetPath() + card.Filename.GetFullName());
|
wxFileName fullpath( m_FolderPicker->GetPath() + card.Filename.GetFullName());
|
||||||
|
|
||||||
|
@ -818,7 +807,6 @@ void Panels::MemoryCardListPanel_Simple::UiDeleteCard( McdSlotItem& card )
|
||||||
}
|
}
|
||||||
|
|
||||||
RefreshSelections();
|
RefreshSelections();
|
||||||
closed_core.AllowResume();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -873,7 +861,6 @@ bool Panels::MemoryCardListPanel_Simple::UiDuplicateCard(McdSlotItem& src, McdSl
|
||||||
wxFileName destfile( basepath + dest.Filename);
|
wxFileName destfile( basepath + dest.Filename);
|
||||||
|
|
||||||
ScopedBusyCursor doh( Cursor_ReallyBusy );
|
ScopedBusyCursor doh( Cursor_ReallyBusy );
|
||||||
ScopedCoreThreadClose closed_core;
|
|
||||||
|
|
||||||
if( !( ( srcfile.FileExists() && wxCopyFile( srcfile.GetFullPath(), destfile.GetFullPath(), true ) )
|
if( !( ( srcfile.FileExists() && wxCopyFile( srcfile.GetFullPath(), destfile.GetFullPath(), true ) )
|
||||||
|| ( !srcfile.FileExists() && CopyDirectory( srcfile.GetFullPath(), destfile.GetFullPath() ) ) ) )
|
|| ( !srcfile.FileExists() && CopyDirectory( srcfile.GetFullPath(), destfile.GetFullPath() ) ) ) )
|
||||||
|
@ -887,7 +874,6 @@ bool Panels::MemoryCardListPanel_Simple::UiDuplicateCard(McdSlotItem& src, McdSl
|
||||||
|
|
||||||
Msgbox::Alert( heading + L"\n\n" + content, _("Copy failed!") );
|
Msgbox::Alert( heading + L"\n\n" + content, _("Copy failed!") );
|
||||||
|
|
||||||
closed_core.AllowResume();
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -903,7 +889,6 @@ bool Panels::MemoryCardListPanel_Simple::UiDuplicateCard(McdSlotItem& src, McdSl
|
||||||
|
|
||||||
Apply();
|
Apply();
|
||||||
DoRefresh();
|
DoRefresh();
|
||||||
closed_core.AllowResume();
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -940,8 +925,6 @@ void Panels::MemoryCardListPanel_Simple::UiRenameCard( McdSlotItem& card )
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScopedCoreThreadClose closed_core;
|
|
||||||
|
|
||||||
bool origEnabled=card.IsEnabled;
|
bool origEnabled=card.IsEnabled;
|
||||||
card.IsEnabled=false;
|
card.IsEnabled=false;
|
||||||
Apply();
|
Apply();
|
||||||
|
@ -951,7 +934,6 @@ void Panels::MemoryCardListPanel_Simple::UiRenameCard( McdSlotItem& card )
|
||||||
Apply();
|
Apply();
|
||||||
Msgbox::Alert( _("Error: Rename could not be completed.\n"), _("Rename memory card") );
|
Msgbox::Alert( _("Error: Rename could not be completed.\n"), _("Rename memory card") );
|
||||||
|
|
||||||
closed_core.AllowResume();
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -960,7 +942,6 @@ void Panels::MemoryCardListPanel_Simple::UiRenameCard( McdSlotItem& card )
|
||||||
Apply();
|
Apply();
|
||||||
|
|
||||||
RefreshSelections();
|
RefreshSelections();
|
||||||
closed_core.AllowResume();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Panels::MemoryCardListPanel_Simple::OnCreateOrDeleteCard(wxCommandEvent& evt)
|
void Panels::MemoryCardListPanel_Simple::OnCreateOrDeleteCard(wxCommandEvent& evt)
|
||||||
|
|
Loading…
Reference in New Issue