PDFViewer: Create OutlineModel items with the correct pointer

This fixes a bug where we would construct a ModelIndex with a pointer to
NonnullRefPtr<OutlineItem>, instead of a pointer to the underlying
OutlineItem, which caused a crash later on when we would try to
dereference that pointer.
This commit is contained in:
Julian Offenhäuser 2023-03-22 17:51:55 +01:00 committed by Andreas Kling
parent fcd4e68959
commit 0d46c27741

View file

@ -130,8 +130,8 @@ GUI::ModelIndex OutlineModel::parent_index(const GUI::ModelIndex& index) const
GUI::ModelIndex OutlineModel::index(int row, int column, const GUI::ModelIndex& parent) const
{
if (!parent.is_valid())
return create_index(row, column, &m_outline->children[row]);
return create_index(row, column, m_outline->children[row].ptr());
auto parent_outline_item = static_cast<PDF::OutlineItem*>(parent.internal_data());
return create_index(row, column, &parent_outline_item->children[row]);
return create_index(row, column, parent_outline_item->children[row].ptr());
}