mirror of
https://github.com/SerenityOS/serenity
synced 2024-09-06 17:06:31 +00:00
Mail: Fix crash caused by migration from NonnullRefPtrVector
When we moved from NonnullRefPtrVector<T> to Vector<NonnullRefPtr<T>>
in commit 8a48246ed1
, the `at()` function
started returning a NonnullRefPtr<T>& instead of T&.
The code calling create_index() was not then updated and ended up taking
a pointer to a temporary NonnullRefPtr<>, instead of an actual object,
leading to a crash after logging in.
This commit is contained in:
parent
dfcd5ffaba
commit
bd853de716
|
@ -21,17 +21,17 @@ GUI::ModelIndex MailboxTreeModel::index(int row, int column, GUI::ModelIndex con
|
||||||
if (!parent.is_valid()) {
|
if (!parent.is_valid()) {
|
||||||
if (m_account_holder.accounts().is_empty())
|
if (m_account_holder.accounts().is_empty())
|
||||||
return {};
|
return {};
|
||||||
return create_index(row, column, &m_account_holder.accounts().at(row));
|
return create_index(row, column, m_account_holder.accounts().at(row));
|
||||||
}
|
}
|
||||||
auto& base_node = *static_cast<BaseNode*>(parent.internal_data());
|
auto& base_node = *static_cast<BaseNode*>(parent.internal_data());
|
||||||
|
|
||||||
if (is<MailboxNode>(base_node)) {
|
if (is<MailboxNode>(base_node)) {
|
||||||
auto& remote_mailbox = verify_cast<MailboxNode>(base_node);
|
auto& remote_mailbox = verify_cast<MailboxNode>(base_node);
|
||||||
return create_index(row, column, &remote_mailbox.children().at(row));
|
return create_index(row, column, remote_mailbox.children().at(row));
|
||||||
}
|
}
|
||||||
|
|
||||||
auto& remote_parent = verify_cast<AccountNode>(base_node);
|
auto& remote_parent = verify_cast<AccountNode>(base_node);
|
||||||
return create_index(row, column, &remote_parent.mailboxes().at(row));
|
return create_index(row, column, remote_parent.mailboxes().at(row));
|
||||||
}
|
}
|
||||||
|
|
||||||
GUI::ModelIndex MailboxTreeModel::parent_index(GUI::ModelIndex const& index) const
|
GUI::ModelIndex MailboxTreeModel::parent_index(GUI::ModelIndex const& index) const
|
||||||
|
|
Loading…
Reference in a new issue