Fix same object count being used for all frames in the FIFO analyzer

If the number of objects varied, this would result in either missing objects on some frames, or too many objects on some frames; the latter case could cause crashes.  Since it used the current frame to get the count, if the FIFO is started before the FIFO analyzer is opened, then the current frame is effectively random, making it hard to reproduce consistently.

This issue has existed since the FIFO analyzer was implemented for Qt.
This commit is contained in:
Pokechu22
2021-03-31 22:43:21 -07:00
parent ef75381a84
commit 28b71c65af
4 changed files with 19 additions and 14 deletions

View File

@ -139,23 +139,22 @@ void FIFOAnalyzer::UpdateTree()
auto* file = FifoPlayer::GetInstance().GetFile();
int object_count = FifoPlayer::GetInstance().GetFrameObjectCount();
int frame_count = file->GetFrameCount();
for (int i = 0; i < frame_count; i++)
const u32 frame_count = file->GetFrameCount();
for (u32 frame = 0; frame < frame_count; frame++)
{
auto* frame_item = new QTreeWidgetItem({tr("Frame %1").arg(i)});
auto* frame_item = new QTreeWidgetItem({tr("Frame %1").arg(frame)});
recording_item->addChild(frame_item);
for (int j = 0; j < object_count; j++)
const u32 object_count = FifoPlayer::GetInstance().GetFrameObjectCount(frame);
for (u32 object = 0; object < object_count; object++)
{
auto* object_item = new QTreeWidgetItem({tr("Object %1").arg(j)});
auto* object_item = new QTreeWidgetItem({tr("Object %1").arg(object)});
frame_item->addChild(object_item);
object_item->setData(0, FRAME_ROLE, i);
object_item->setData(0, OBJECT_ROLE, j);
object_item->setData(0, FRAME_ROLE, frame);
object_item->setData(0, OBJECT_ROLE, object);
}
}
}

View File

@ -262,7 +262,7 @@ void FIFOPlayerWindow::UpdateInfo()
m_info_label->setText(
tr("%1 frame(s)\n%2 object(s)\nCurrent Frame: %3")
.arg(QString::number(file->GetFrameCount()),
QString::number(FifoPlayer::GetInstance().GetFrameObjectCount()),
QString::number(FifoPlayer::GetInstance().GetCurrentFrameObjectCount()),
QString::number(FifoPlayer::GetInstance().GetCurrentFrameNum())));
return;
}