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:
Jonathan Li 2015-10-04 20:49:53 +01:00
parent c17eacec04
commit 1cbae66bb3
4 changed files with 6 additions and 54 deletions

View File

@ -155,7 +155,6 @@ namespace Dialogs
protected:
Panels::BaseMcdListPanel* m_panel_mcdlist;
bool m_needs_suspending;
public:
virtual ~McdConfigDialog() throw() {}
@ -163,9 +162,6 @@ namespace Dialogs
static wxString GetNameStatic() { return L"McdConfig"; }
wxString GetDialogName() const { return GetNameStatic(); }
virtual bool Show( bool show=true );
virtual int ShowModal();
protected:
virtual wxString& GetConfSettingsTabName() const { return g_Conf->McdSettingsTabName; }
//void OnMultitapClicked( wxCommandEvent& evt );

View File

@ -101,7 +101,6 @@ Dialogs::McdConfigDialog::McdConfigDialog( wxWindow* parent )
: BaseConfigurationDialog( parent, _("MemoryCard Manager"), 600 )
{
m_panel_mcdlist = new MemoryCardListPanel_Simple( this );
m_needs_suspending = false;
wxFlexGridSizer* s_flex=new wxFlexGridSizer(3,1, 0, 0);
s_flex->AddGrowableCol(0);
@ -152,30 +151,3 @@ void Dialogs::McdConfigDialog::OnMultitapClicked( wxCommandEvent& evt )
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();
}

View File

@ -15,6 +15,7 @@
#include "PrecompiledHeader.h"
#include "App.h"
#include "CDVD/CDVD.h"
#include "GS.h"
@ -37,7 +38,9 @@ void MainEmuFrame::Menu_SysSettings_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)

View File

@ -618,9 +618,6 @@ void Panels::MemoryCardListPanel_Simple::Apply()
{
_parent::Apply();
ScopedCoreThreadClose closed_core;
closed_core.AllowResume();
int used=0;
Console.WriteLn( L"Apply Memory cards:" );
for( uint slot=0; slot<8; ++slot )
@ -736,8 +733,6 @@ void Panels::MemoryCardListPanel_Simple::UiCreateNewCard( McdSlotItem& card )
return;
}
ScopedCoreThreadClose closed_core;
Dialogs::CreateMemoryCardDialog dialog( this, m_FolderPicker->GetPath(), L"my memory card" );
wxWindowID result = dialog.ShowModal();
@ -756,7 +751,6 @@ void Panels::MemoryCardListPanel_Simple::UiCreateNewCard( McdSlotItem& card )
Apply();
RefreshSelections();
closed_core.AllowResume();
}
void Panels::MemoryCardListPanel_Simple::UiConvertCard( McdSlotItem& card ) {
@ -765,8 +759,6 @@ void Panels::MemoryCardListPanel_Simple::UiConvertCard( McdSlotItem& card ) {
return;
}
ScopedCoreThreadClose closed_core;
AppConfig::McdOptions config;
config.Filename = card.Filename.GetFullName();
config.Enabled = card.IsEnabled;
@ -778,8 +770,6 @@ void Panels::MemoryCardListPanel_Simple::UiConvertCard( McdSlotItem& card ) {
Apply();
RefreshSelections();
}
closed_core.AllowResume();
}
void Panels::MemoryCardListPanel_Simple::UiDeleteCard( McdSlotItem& card )
@ -804,7 +794,6 @@ void Panels::MemoryCardListPanel_Simple::UiDeleteCard( McdSlotItem& card )
if( result )
{
ScopedCoreThreadClose closed_core;
wxFileName fullpath( m_FolderPicker->GetPath() + card.Filename.GetFullName());
@ -818,7 +807,6 @@ void Panels::MemoryCardListPanel_Simple::UiDeleteCard( McdSlotItem& card )
}
RefreshSelections();
closed_core.AllowResume();
}
}
@ -873,7 +861,6 @@ bool Panels::MemoryCardListPanel_Simple::UiDuplicateCard(McdSlotItem& src, McdSl
wxFileName destfile( basepath + dest.Filename);
ScopedBusyCursor doh( Cursor_ReallyBusy );
ScopedCoreThreadClose closed_core;
if( !( ( srcfile.FileExists() && wxCopyFile( srcfile.GetFullPath(), destfile.GetFullPath(), true ) )
|| ( !srcfile.FileExists() && CopyDirectory( srcfile.GetFullPath(), destfile.GetFullPath() ) ) ) )
@ -886,8 +873,7 @@ bool Panels::MemoryCardListPanel_Simple::UiDuplicateCard(McdSlotItem& src, McdSl
wxString content;
Msgbox::Alert( heading + L"\n\n" + content, _("Copy failed!") );
closed_core.AllowResume();
return false;
}
@ -903,7 +889,6 @@ bool Panels::MemoryCardListPanel_Simple::UiDuplicateCard(McdSlotItem& src, McdSl
Apply();
DoRefresh();
closed_core.AllowResume();
return true;
}
@ -940,8 +925,6 @@ void Panels::MemoryCardListPanel_Simple::UiRenameCard( McdSlotItem& card )
break;
}
ScopedCoreThreadClose closed_core;
bool origEnabled=card.IsEnabled;
card.IsEnabled=false;
Apply();
@ -950,8 +933,7 @@ void Panels::MemoryCardListPanel_Simple::UiRenameCard( McdSlotItem& card )
card.IsEnabled=origEnabled;
Apply();
Msgbox::Alert( _("Error: Rename could not be completed.\n"), _("Rename memory card") );
closed_core.AllowResume();
return;
}
@ -960,7 +942,6 @@ void Panels::MemoryCardListPanel_Simple::UiRenameCard( McdSlotItem& card )
Apply();
RefreshSelections();
closed_core.AllowResume();
}
void Panels::MemoryCardListPanel_Simple::OnCreateOrDeleteCard(wxCommandEvent& evt)