Fixed a crash that would occur if a new watch were added by entering a watch name.

Code style updates.
This commit is contained in:
skidau 2014-10-26 23:23:45 +11:00
parent 7eebbcdca7
commit 4570dd7eeb
9 changed files with 53 additions and 51 deletions

View File

@ -280,7 +280,7 @@ void Watches::Update(int count, u32 em_address)
m_Watches.at(count).iAddress = em_address;
}
void Watches::UpdateName(int count, std::string name)
void Watches::UpdateName(int count, const std::string name)
{
m_Watches.at(count).name = name;
}

View File

@ -125,7 +125,7 @@ public:
void Add(const TWatch& bp);
void Update(int count, u32 em_address);
void UpdateName(int count, std::string name);
void UpdateName(int count, const std::string name);
// Remove Breakpoint
void Remove(u32 _iAddress);

View File

@ -58,10 +58,18 @@ static void UpdateWatchAddr(int count, u32 value)
PowerPC::watches.Update(count - 1, value);
}
static void SetWatchName(int count, std::string value)
static void SetWatchName(int count, const std::string value)
{
if ((count - 1) < PowerPC::watches.GetWatches().size())
{
PowerPC::watches.UpdateName(count - 1, value);
}
else
{
PowerPC::watches.Add(0);
PowerPC::watches.UpdateName(PowerPC::watches.GetWatches().size() - 1, value);
}
}
static void SetWatchValue(int count, u32 value)
{
@ -191,10 +199,8 @@ wxGridCellAttr *CWatchTable::GetAttr(int row, int col, wxGridCellAttr::wxAttrKin
else
{
bool red = false;
switch (col)
{
case 1: red = m_CachedWatchHasChanged[row]; break;
}
if (col == 1)
red = m_CachedWatchHasChanged[row];
attr->SetTextColour(red ? *wxRED : *wxBLACK);
@ -269,11 +275,13 @@ void CWatchView::OnPopupMenu(wxCommandEvent& event)
{
case IDM_DELETEWATCH:
strNewVal = GetValueByRowCol(m_selectedRow, 1);
TryParse("0x" + WxStrToStr(strNewVal), &m_selectedAddress);
if (TryParse("0x" + WxStrToStr(strNewVal), &m_selectedAddress))
{
PowerPC::watches.Remove(m_selectedAddress);
if (watch_window)
watch_window->NotifyUpdate();
Refresh();
}
break;
case IDM_ADDMEMCHECK:
MemCheck.StartAddress = m_selectedAddress;

View File

@ -661,9 +661,7 @@ void CFrame::BootGame(const std::string& filename)
if (!bootfile.empty())
{
StartGame(bootfile);
if (UseDebugger)
{
if (g_pCodeWindow)
if (UseDebugger && g_pCodeWindow)
{
if (g_pCodeWindow->m_WatchWindow)
g_pCodeWindow->m_WatchWindow->LoadAll();
@ -672,7 +670,6 @@ void CFrame::BootGame(const std::string& filename)
}
}
}
}
// Open file to boot
void CFrame::OnOpen(wxCommandEvent& WXUNUSED (event))
@ -1178,9 +1175,7 @@ void CFrame::DoStop()
}
}
if (UseDebugger)
{
if (g_pCodeWindow)
if (UseDebugger && g_pCodeWindow)
{
if (g_pCodeWindow->m_WatchWindow)
{
@ -1197,7 +1192,6 @@ void CFrame::DoStop()
g_symbolDB.Clear();
Host_NotifyMapLoaded();
}
}
// TODO: Show the author/description dialog here
if (Movie::IsRecordingInput())