Thanks for the reply.
I don't think a QPersistentModelIndex helps here.
There is only a single line after the QMessageBox where I call...
return QAbstractItemModel::hasChildren(parent);
To copy to clipboard, switch view to plain text mode
If I were to store the result of this call as a boolean variable at the top of the method and just return it, then I'm not using the index at all after the QMessageBox and it still segfaults.
bool TreeModel
::hasChildren(const QModelIndex &parent
) const {
std::ostringstream oss;
if (!parent.isValid()) {
oss << "hasChildren root" << std::endl;
} else {
oss << "hasChildren (" << parent.row() << "," << parent.column() << ")" << std::endl;
}
return ret;
}
bool TreeModel::hasChildren(const QModelIndex &parent) const
{
bool ret = QAbstractItemModel::hasChildren(parent);
QPersistentModelIndex tmp = QPersistentModelIndex(parent);
std::ostringstream oss;
if (!parent.isValid()) {
oss << "hasChildren root" << std::endl;
} else {
oss << "hasChildren (" << parent.row() << "," << parent.column() << ")" << std::endl;
}
oss << QAbstractItemModel::hasChildren(parent) << std::endl;
QMessageBox::information((QWidget*)QAbstractItemModel::parent(), "TITLE", QString::fromStdString(oss.str()));
return ret;
}
To copy to clipboard, switch view to plain text mode
Bookmarks