diff options
author | Tim Ledbetter <timledbetter@gmail.com> | 2023-03-16 00:14:25 +0000 |
---|---|---|
committer | Jelle Raaijmakers <jelle@gmta.nl> | 2023-03-16 08:05:58 +0100 |
commit | 2fe4be40afbeee0c99c4a04054cb01f309e6b735 (patch) | |
tree | 62c319781ef5226316fa5f2b1d45c7cf24236324 /Userland/Libraries | |
parent | 49b07cda12dfc808f2026952bd26c143e11e9b7f (diff) | |
download | serenity-2fe4be40afbeee0c99c4a04054cb01f309e6b735.zip |
LibGUI: Store correct address in TreeViewModel's ModelIndices
After `8a48246` m_nodes[row] amd m_child_nodes[row] return a
NonnullRefPtr<Node>, so we were putting the wrong address
into the ModelIndex's data.
Diffstat (limited to 'Userland/Libraries')
-rw-r--r-- | Userland/Libraries/LibGUI/TreeViewModel.cpp | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/Userland/Libraries/LibGUI/TreeViewModel.cpp b/Userland/Libraries/LibGUI/TreeViewModel.cpp index a03e20e785..b17c6ea14c 100644 --- a/Userland/Libraries/LibGUI/TreeViewModel.cpp +++ b/Userland/Libraries/LibGUI/TreeViewModel.cpp @@ -13,12 +13,12 @@ ModelIndex TreeViewModel::index(int row, int column, ModelIndex const& parent) c if (!parent.is_valid()) { if (static_cast<size_t>(row) >= m_nodes.size()) return {}; - return create_index(row, column, &m_nodes[row]); + return create_index(row, column, m_nodes[row].ptr()); } auto const& parent_node = *static_cast<Node const*>(parent.internal_data()); if (static_cast<size_t>(row) >= parent_node.child_nodes().size()) return {}; - auto const* child = &parent_node.child_nodes()[row]; + auto const* child = parent_node.child_nodes()[row].ptr(); return create_index(row, column, child); } @@ -32,7 +32,7 @@ ModelIndex TreeViewModel::parent_index(ModelIndex const& index) const return {}; if (parent_node->parent_node() == nullptr) { for (size_t row = 0; row < m_nodes.size(); row++) - if (m_nodes[row] == parent_node) + if (m_nodes[row].ptr() == parent_node) return create_index(static_cast<int>(row), 0, parent_node); VERIFY_NOT_REACHED(); } |