Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Fix warning: invalid inserted rows reported by source model

parent 76bf2c1f
......@@ -64,13 +64,13 @@ TreeItem::~TreeItem()
std::shared_ptr<TreeItem> TreeItem::appendChild(const QList<QVariant> &data)
{
if (auto ptr = m_model.lock()) {
ptr->notifyRowAboutToAppend(shared_from_this());
auto child = construct(data, ptr, shared_from_this());
child->m_depth = m_depth + 1;
int id = child->getId();
m_childItems.push_back(child);
auto it = std::prev(m_childItems.end());
m_iteratorTable[id] = it;
ptr->notifyRowAboutToAppend(shared_from_this());
ptr->notifyRowAppended();
return child;
}
......@@ -82,12 +82,12 @@ std::shared_ptr<TreeItem> TreeItem::appendChild(const QList<QVariant> &data)
void TreeItem::appendChild(std::shared_ptr<TreeItem> child)
{
if (auto ptr = m_model.lock()) {
ptr->notifyRowAboutToAppend(shared_from_this());
child->m_depth = m_depth + 1;
child->m_parentItem = shared_from_this();
int id = child->getId();
auto it = m_childItems.insert(m_childItems.end(), std::move(child));
m_iteratorTable[id] = it;
ptr->notifyRowAboutToAppend(shared_from_this());
ptr->notifyRowAppended();
} else {
qDebug() << "ERROR: Something went wrong when appending child in TreeItem. Model is not available anymore";
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment