fix: crash when renaming top-level folder in qt (#2230)

This commit is contained in:
Charles Kerr 2021-11-25 19:14:14 -06:00 committed by GitHub
parent dc36787378
commit 8d2ca760e6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 5 additions and 3 deletions

View File

@ -91,9 +91,9 @@ public:
} // namespace
FileTreeModel::FileTreeModel(QObject* parent, bool is_editable)
: QAbstractItemModel(parent)
, root_item_(new FileTreeItem)
, is_editable_(is_editable)
: QAbstractItemModel{ parent }
, root_item_{ new FileTreeItem }
, is_editable_{ is_editable }
{
}
@ -320,6 +320,8 @@ void FileTreeModel::clear()
{
beginResetModel();
clearSubtree(QModelIndex());
delete root_item_;
root_item_ = new FileTreeItem{};
endResetModel();
assert(index_cache_.isEmpty());