From 5ada887f94b5a571446c65bd4f1e9298dd8e2fea Mon Sep 17 00:00:00 2001 From: Lioncash Date: Tue, 24 Mar 2015 09:37:20 -0400 Subject: [PATCH] DolphinWX: Get rid of wxGrid-based casts in the debugger. This technically also fixes a memory leak in WatchView.cpp, because the table setting was done such that the grid wouldn't take ownership of the table, which means said table wouldn't be deleted in the grid's destructor. --- Source/Core/DolphinWX/Debugger/DSPRegisterView.cpp | 6 ++++-- Source/Core/DolphinWX/Debugger/DSPRegisterView.h | 4 ++++ Source/Core/DolphinWX/Debugger/RegisterView.cpp | 6 ++++-- Source/Core/DolphinWX/Debugger/RegisterView.h | 3 +++ Source/Core/DolphinWX/Debugger/WatchView.cpp | 6 ++++-- Source/Core/DolphinWX/Debugger/WatchView.h | 1 + Source/Core/DolphinWX/Debugger/WatchWindow.h | 4 +++- 7 files changed, 23 insertions(+), 7 deletions(-) diff --git a/Source/Core/DolphinWX/Debugger/DSPRegisterView.cpp b/Source/Core/DolphinWX/Debugger/DSPRegisterView.cpp index e62bfcb781..0eece2d15c 100644 --- a/Source/Core/DolphinWX/Debugger/DSPRegisterView.cpp +++ b/Source/Core/DolphinWX/Debugger/DSPRegisterView.cpp @@ -77,7 +77,9 @@ wxGridCellAttr *CDSPRegTable::GetAttr(int row, int col, wxGridCellAttr::wxAttrKi DSPRegisterView::DSPRegisterView(wxWindow *parent, wxWindowID id) : wxGrid(parent, id, wxDefaultPosition, wxSize(130, 120)) { - SetTable(new CDSPRegTable(), true); + m_register_table = new CDSPRegTable(); + + SetTable(m_register_table, true); SetRowLabelSize(0); SetColLabelSize(0); DisableDragRowSize(); @@ -87,6 +89,6 @@ DSPRegisterView::DSPRegisterView(wxWindow *parent, wxWindowID id) void DSPRegisterView::Update() { - ((CDSPRegTable *)GetTable())->UpdateCachedRegs(); + m_register_table->UpdateCachedRegs(); ForceRefresh(); } diff --git a/Source/Core/DolphinWX/Debugger/DSPRegisterView.h b/Source/Core/DolphinWX/Debugger/DSPRegisterView.h index 55995e0e97..475879ca2e 100644 --- a/Source/Core/DolphinWX/Debugger/DSPRegisterView.h +++ b/Source/Core/DolphinWX/Debugger/DSPRegisterView.h @@ -44,4 +44,8 @@ class DSPRegisterView : public wxGrid public: DSPRegisterView(wxWindow* parent, wxWindowID id = wxID_ANY); void Update() override; + +private: + // Owned by wx. Deleted implicitly upon destruction. + CDSPRegTable* m_register_table; }; diff --git a/Source/Core/DolphinWX/Debugger/RegisterView.cpp b/Source/Core/DolphinWX/Debugger/RegisterView.cpp index f7a268cad0..5e35ef84a3 100644 --- a/Source/Core/DolphinWX/Debugger/RegisterView.cpp +++ b/Source/Core/DolphinWX/Debugger/RegisterView.cpp @@ -248,7 +248,9 @@ wxGridCellAttr *CRegTable::GetAttr(int row, int col, wxGridCellAttr::wxAttrKind) CRegisterView::CRegisterView(wxWindow *parent, wxWindowID id) : wxGrid(parent, id) { - SetTable(new CRegTable(), true); + m_register_table = new CRegTable(); + + SetTable(m_register_table, true); SetRowLabelSize(0); SetColLabelSize(0); DisableDragRowSize(); @@ -262,7 +264,7 @@ CRegisterView::CRegisterView(wxWindow *parent, wxWindowID id) void CRegisterView::Update() { ForceRefresh(); - ((CRegTable *)GetTable())->UpdateCachedRegs(); + m_register_table->UpdateCachedRegs(); } void CRegisterView::OnMouseDownR(wxGridEvent& event) diff --git a/Source/Core/DolphinWX/Debugger/RegisterView.h b/Source/Core/DolphinWX/Debugger/RegisterView.h index b6522585c8..af4d55843d 100644 --- a/Source/Core/DolphinWX/Debugger/RegisterView.h +++ b/Source/Core/DolphinWX/Debugger/RegisterView.h @@ -76,4 +76,7 @@ public: private: u32 m_selectedAddress = 0; + + // Owned by wx. Deleted implicitly upon destruction. + CRegTable* m_register_table; }; diff --git a/Source/Core/DolphinWX/Debugger/WatchView.cpp b/Source/Core/DolphinWX/Debugger/WatchView.cpp index 8f88fb637b..d2349a94e3 100644 --- a/Source/Core/DolphinWX/Debugger/WatchView.cpp +++ b/Source/Core/DolphinWX/Debugger/WatchView.cpp @@ -215,7 +215,9 @@ wxGridCellAttr* CWatchTable::GetAttr(int row, int col, wxGridCellAttr::wxAttrKin CWatchView::CWatchView(wxWindow* parent, wxWindowID id) : wxGrid(parent, id) { - SetTable(new CWatchTable(), false); + m_watch_table = new CWatchTable(); + + SetTable(m_watch_table, true); SetRowLabelSize(0); SetColLabelSize(0); DisableDragRowSize(); @@ -229,7 +231,7 @@ void CWatchView::Update() if (PowerPC::GetState() != PowerPC::CPU_POWERDOWN) { ForceRefresh(); - ((CWatchTable *)GetTable())->UpdateWatch(); + m_watch_table->UpdateWatch(); } } diff --git a/Source/Core/DolphinWX/Debugger/WatchView.h b/Source/Core/DolphinWX/Debugger/WatchView.h index 61cc82bb78..4235628d18 100644 --- a/Source/Core/DolphinWX/Debugger/WatchView.h +++ b/Source/Core/DolphinWX/Debugger/WatchView.h @@ -52,4 +52,5 @@ public: private: u32 m_selectedAddress = 0; u32 m_selectedRow = 0; + CWatchTable* m_watch_table; }; diff --git a/Source/Core/DolphinWX/Debugger/WatchWindow.h b/Source/Core/DolphinWX/Debugger/WatchWindow.h index 4eb2040878..09668a7af3 100644 --- a/Source/Core/DolphinWX/Debugger/WatchWindow.h +++ b/Source/Core/DolphinWX/Debugger/WatchWindow.h @@ -34,8 +34,10 @@ public: void LoadAll(); private: + void CreateGUIControls(); + wxAuiManager m_mgr; + // Owned by wx. Deleted implicitly upon destruction. CWatchView* m_GPRGridView; - void CreateGUIControls(); };