Clear m_object_data_offsets first and require it before UpdateDescription

It still tries to update the description on clearing, potentially with bad data.
This commit is contained in:
Pokechu22 2021-02-19 20:03:31 -08:00
parent 28b71c65af
commit 05bd15a928

View File

@ -161,8 +161,12 @@ void FIFOAnalyzer::UpdateTree()
void FIFOAnalyzer::UpdateDetails()
{
m_detail_list->clear();
// Clearing the detail list can update the selection, which causes UpdateDescription to be called
// immediately. However, the object data offsets have not been recalculated yet, which can cause
// the wrong data to be used, potentially leading to out of bounds data or other bad things.
// Clear m_object_data_offsets first, so that UpdateDescription exits immediately.
m_object_data_offsets.clear();
m_detail_list->clear();
if (!FifoPlayer::GetInstance().IsPlaying())
return;
@ -472,7 +476,7 @@ void FIFOAnalyzer::UpdateDescription()
auto items = m_tree_widget->selectedItems();
if (items.isEmpty())
if (items.isEmpty() || m_object_data_offsets.empty())
return;
int frame_nr = items[0]->data(0, FRAME_ROLE).toInt();