diff --git a/pcsx2/CDVD/BlockdumpFileReader.cpp b/pcsx2/CDVD/BlockdumpFileReader.cpp index b4f9f736a1..8d1b073763 100644 --- a/pcsx2/CDVD/BlockdumpFileReader.cpp +++ b/pcsx2/CDVD/BlockdumpFileReader.cpp @@ -34,7 +34,7 @@ bool BlockdumpFileReader::DetectBlockdump(AsyncFileReader* reader) reader->SetBlockSize(1); - char buf[4]; + char buf[5] = {0}; reader->ReadSync(buf, 0, 4); bool isbd = (strncmp(buf, "BDV2", 4) == 0); diff --git a/pcsx2/Linux/LnxFlatFileReader.cpp b/pcsx2/Linux/LnxFlatFileReader.cpp index 1b2c6b5213..b04dac60bd 100644 --- a/pcsx2/Linux/LnxFlatFileReader.cpp +++ b/pcsx2/Linux/LnxFlatFileReader.cpp @@ -66,7 +66,7 @@ int FlatFileReader::FinishRead(void) int min_nr = 1; int max_nr = 1; - struct io_event* events = new io_event[max_nr]; + struct io_event events[max_nr]; int event = io_getevents(m_aio_context, min_nr, max_nr, events, NULL); if (event < 1) { diff --git a/pcsx2/gui/Debugger/CtrlRegisterList.cpp b/pcsx2/gui/Debugger/CtrlRegisterList.cpp index 28ebdc0c99..fcc38d0120 100644 --- a/pcsx2/gui/Debugger/CtrlRegisterList.cpp +++ b/pcsx2/gui/Debugger/CtrlRegisterList.cpp @@ -52,6 +52,7 @@ CtrlRegisterList::CtrlRegisterList(wxWindow* parent, DebugInterface* _cpu) category = 0; maxBits = 128; lastPc = 0xFFFFFFFF; + resolvePointerStrings = false; for (int i = 0; i < cpu->getRegisterCategoryCount(); i++) { @@ -80,6 +81,13 @@ CtrlRegisterList::CtrlRegisterList(wxWindow* parent, DebugInterface* _cpu) SetScrollbars(1, rowHeight, actualSize.x, actualSize.y / rowHeight, 0, 0); } +CtrlRegisterList::~CtrlRegisterList() +{ + for (auto& regs : changedCategories) + delete[] regs; + +} + wxSize CtrlRegisterList::getOptimalSize() const { int columnChars = 0; diff --git a/pcsx2/gui/Debugger/CtrlRegisterList.h b/pcsx2/gui/Debugger/CtrlRegisterList.h index 0f2e0f620b..cd0709ae18 100644 --- a/pcsx2/gui/Debugger/CtrlRegisterList.h +++ b/pcsx2/gui/Debugger/CtrlRegisterList.h @@ -23,14 +23,15 @@ class CtrlRegisterList: public wxScrolledWindow { public: CtrlRegisterList(wxWindow* parent, DebugInterface* _cpu); - + ~CtrlRegisterList(); + void mouseEvent(wxMouseEvent& evt); void keydownEvent(wxKeyEvent& evt); void onPopupClick(wxCommandEvent& evt); void sizeEvent(wxSizeEvent& evt); void redraw(); DECLARE_EVENT_TABLE() - + virtual wxSize GetMinClientSize() const { wxSize optimalSize = getOptimalSize(); diff --git a/pcsx2/gui/SysState.cpp b/pcsx2/gui/SysState.cpp index bb862cd618..ac1717de3c 100644 --- a/pcsx2/gui/SysState.cpp +++ b/pcsx2/gui/SysState.cpp @@ -42,9 +42,10 @@ class BaseSavestateEntry { protected: BaseSavestateEntry() {} - virtual ~BaseSavestateEntry() throw() {} public: + virtual ~BaseSavestateEntry() throw() {} + virtual wxString GetFilename() const=0; virtual void FreezeIn( pxInputStream& reader ) const=0; virtual void FreezeOut( SaveStateBase& writer ) const=0; @@ -142,10 +143,12 @@ void PluginSavestateEntry::FreezeOut( SaveStateBase& writer ) const class SavestateEntry_EmotionMemory : public MemorySavestateEntry { public: + virtual ~SavestateEntry_EmotionMemory() throw() {} + wxString GetFilename() const { return L"eeMemory.bin"; } u8* GetDataPtr() const { return eeMem->Main; } uint GetDataSize() const { return sizeof(eeMem->Main); } - + virtual void FreezeIn( pxInputStream& reader ) const { SysClearExecutionCache(); @@ -156,6 +159,8 @@ public: class SavestateEntry_IopMemory : public MemorySavestateEntry { public: + virtual ~SavestateEntry_IopMemory() throw() {} + wxString GetFilename() const { return L"iopMemory.bin"; } u8* GetDataPtr() const { return iopMem->Main; } uint GetDataSize() const { return sizeof(iopMem->Main); } @@ -164,6 +169,8 @@ public: class SavestateEntry_HwRegs : public MemorySavestateEntry { public: + virtual ~SavestateEntry_HwRegs() throw() {} + wxString GetFilename() const { return L"eeHwRegs.bin"; } u8* GetDataPtr() const { return eeHw; } uint GetDataSize() const { return sizeof(eeHw); } @@ -172,6 +179,8 @@ public: class SavestateEntry_IopHwRegs : public MemorySavestateEntry { public: + virtual ~SavestateEntry_IopHwRegs() throw() {} + wxString GetFilename() const { return L"iopHwRegs.bin"; } u8* GetDataPtr() const { return iopHw; } uint GetDataSize() const { return sizeof(iopHw); } @@ -180,6 +189,8 @@ public: class SavestateEntry_Scratchpad : public MemorySavestateEntry { public: + virtual ~SavestateEntry_Scratchpad() throw() {} + wxString GetFilename() const { return L"Scratchpad.bin"; } u8* GetDataPtr() const { return eeMem->Scratch; } uint GetDataSize() const { return sizeof(eeMem->Scratch); } @@ -188,6 +199,8 @@ public: class SavestateEntry_VU0mem : public MemorySavestateEntry { public: + virtual ~SavestateEntry_VU0mem() throw() {} + wxString GetFilename() const { return L"vu0Memory.bin"; } u8* GetDataPtr() const { return vuRegs[0].Mem; } uint GetDataSize() const { return VU0_MEMSIZE; } @@ -196,6 +209,8 @@ public: class SavestateEntry_VU1mem : public MemorySavestateEntry { public: + virtual ~SavestateEntry_VU1mem() throw() {} + wxString GetFilename() const { return L"vu1Memory.bin"; } u8* GetDataPtr() const { return vuRegs[1].Mem; } uint GetDataSize() const { return VU1_MEMSIZE; } @@ -204,6 +219,8 @@ public: class SavestateEntry_VU0prog : public MemorySavestateEntry { public: + virtual ~SavestateEntry_VU0prog() throw() {} + wxString GetFilename() const { return L"vu0MicroMem.bin"; } u8* GetDataPtr() const { return vuRegs[0].Micro; } uint GetDataSize() const { return VU0_PROGSIZE; } @@ -212,6 +229,8 @@ public: class SavestateEntry_VU1prog : public MemorySavestateEntry { public: + virtual ~SavestateEntry_VU1prog() throw() {} + wxString GetFilename() const { return L"vu1MicroMem.bin"; } u8* GetDataPtr() const { return vuRegs[1].Micro; } uint GetDataSize() const { return VU1_PROGSIZE; } @@ -227,42 +246,26 @@ public: // would not be useful). // -static const uint NumSavestateEntries = 9 + PluginId_Count; +static const std::unique_ptr SavestateEntries[] = { + std::unique_ptr(new SavestateEntry_EmotionMemory), + std::unique_ptr(new SavestateEntry_IopMemory), + std::unique_ptr(new SavestateEntry_HwRegs), + std::unique_ptr(new SavestateEntry_IopHwRegs), + std::unique_ptr(new SavestateEntry_Scratchpad), + std::unique_ptr(new SavestateEntry_VU0mem), + std::unique_ptr(new SavestateEntry_VU1mem), + std::unique_ptr(new SavestateEntry_VU0prog), + std::unique_ptr(new SavestateEntry_VU1prog), -class SavestateEntryPack : public ScopedAlloc -{ - typedef ScopedAlloc _parent; - -public: - SavestateEntryPack() - : _parent( NumSavestateEntries ) - { - uint i = 0; // more convenient in case we re-arrange anything... - - this->operator[](i++) = new SavestateEntry_EmotionMemory; - this->operator[](i++) = new SavestateEntry_IopMemory; - this->operator[](i++) = new SavestateEntry_HwRegs; - this->operator[](i++) = new SavestateEntry_IopHwRegs; - this->operator[](i++) = new SavestateEntry_Scratchpad; - this->operator[](i++) = new SavestateEntry_VU0mem; - this->operator[](i++) = new SavestateEntry_VU1mem; - this->operator[](i++) = new SavestateEntry_VU0prog; - this->operator[](i++) = new SavestateEntry_VU1prog; - - this->operator[](i++) = new PluginSavestateEntry( PluginId_GS ); - this->operator[](i++) = new PluginSavestateEntry( PluginId_PAD ); - this->operator[](i++) = new PluginSavestateEntry( PluginId_SPU2 ); - this->operator[](i++) = new PluginSavestateEntry( PluginId_CDVD ); - this->operator[](i++) = new PluginSavestateEntry( PluginId_USB ); - this->operator[](i++) = new PluginSavestateEntry( PluginId_FW ); - this->operator[](i++) = new PluginSavestateEntry( PluginId_DEV9 ); - } - - using _parent::operator[]; + std::unique_ptr(new PluginSavestateEntry( PluginId_GS )), + std::unique_ptr(new PluginSavestateEntry( PluginId_PAD )), + std::unique_ptr(new PluginSavestateEntry( PluginId_SPU2 )), + std::unique_ptr(new PluginSavestateEntry( PluginId_CDVD )), + std::unique_ptr(new PluginSavestateEntry( PluginId_USB )), + std::unique_ptr(new PluginSavestateEntry( PluginId_FW )), + std::unique_ptr(new PluginSavestateEntry( PluginId_DEV9 )) }; -static const SavestateEntryPack SavestateEntries; - // It's bad mojo to have savestates trying to read and write from the same file at the // same time. To prevent that we use this mutex lock, which is used by both the // CompressThread and the UnzipFromDisk events. (note that CompressThread locks the @@ -275,7 +278,7 @@ static void CheckVersion( pxInputStream& thr ) { u32 savever; thr.Read( savever ); - + // Major version mismatch. Means we can't load this savestate at all. Support for it // was removed entirely. if( savever > g_SaveVersion ) @@ -336,7 +339,7 @@ protected: internals.SetDataSize( saveme.GetCurrentPos() - internals.GetDataIndex() ); m_dest_list->Add( internals ); - for (uint i=0; iFreezeOut( saveme ); @@ -527,10 +530,10 @@ protected: bool foundVersion = false; //bool foundScreenshot = false; - //bool foundEntry[numSavestateEntries] = false; + //bool foundEntry[ArraySize(SavestateEntries)] = false; std::unique_ptr foundInternal; - std::unique_ptr foundEntry[NumSavestateEntries]; + std::unique_ptr foundEntry[ArraySize(SavestateEntries)]; while(true) { @@ -561,7 +564,7 @@ protected: foundScreenshot = true; }*/ - for (uint i=0; iGetName().CmpNoCase(SavestateEntries[i]->GetFilename()) == 0) { @@ -582,7 +585,7 @@ protected: // Log any parts and pieces that are missing, and then generate an exception. bool throwIt = false; - for (uint i=0; iInitGamepadConfiguration(); - m_frm_gamepad_config->Show(true); + GamepadConfiguration gamepad_config(gamepad_id, this); + + gamepad_config.InitGamepadConfiguration(); + gamepad_config.ShowModal(); } else if(bt_id == JoyL_config) // If the button ID is equals to the JoyL_config button ID { - m_frm_joystick_config = new JoystickConfiguration(gamepad_id, true, this); - m_frm_joystick_config->InitJoystickConfiguration(); - m_frm_joystick_config->Show(true); + JoystickConfiguration joystick_config(gamepad_id, true, this); + + joystick_config.InitJoystickConfiguration(); + joystick_config.ShowModal(); } else if(bt_id == JoyR_config) // If the button ID is equals to the JoyR_config button ID { - m_frm_joystick_config = new JoystickConfiguration(gamepad_id, false, this); - m_frm_joystick_config->InitJoystickConfiguration(); - m_frm_joystick_config->Show(true); + JoystickConfiguration joystick_config(gamepad_id, false, this); + + joystick_config.InitJoystickConfiguration(); + joystick_config.ShowModal(); } else if(bt_id == Set_all) // If the button ID is equals to the Set_all button ID { @@ -696,7 +699,8 @@ void Dialog::repopulate() // Main void DisplayDialog() { - Dialog* dialog = new Dialog(); - dialog->InitDialog(); - dialog->Show(true); + Dialog dialog; + + dialog.InitDialog(); + dialog.ShowModal(); } diff --git a/plugins/onepad/Linux/dialog.h b/plugins/onepad/Linux/dialog.h index 765fd4e76d..ef8e5c49ad 100644 --- a/plugins/onepad/Linux/dialog.h +++ b/plugins/onepad/Linux/dialog.h @@ -63,7 +63,7 @@ enum gui_buttons { #define DEFAULT_WIDTH 1000 #define DEFAULT_HEIGHT 740 -class Dialog : public wxFrame +class Dialog : public wxDialog { // Panels opPanel* m_pan_tabs[GAMEPAD_NUMBER]; // Gamepad Tabs box @@ -80,10 +80,6 @@ class Dialog : public wxFrame // Map the key pressed with the feedback image id std::map m_map_images[GAMEPAD_NUMBER]; - // Frame - GamepadConfiguration* m_frm_gamepad_config; // Gamepad Configuration frame - JoystickConfiguration* m_frm_joystick_config; // Joystick Configuration frame - // methods void config_key(int, int); void clear_key(int, int);