fix crash when directory is changed

This commit is contained in:
alison wright 2019-10-08 23:58:52 -04:00
parent 881fa8c9bd
commit ed5f825b5a

View File

@ -98,9 +98,9 @@ namespace Arc {
return Qt::NoItemFlags; return Qt::NoItemFlags;
} else { } else {
return Qt::ItemIsSelectable | return Qt::ItemIsSelectable |
Qt::ItemIsDragEnabled | Qt::ItemIsDragEnabled |
Qt::ItemIsEnabled | Qt::ItemIsEnabled |
Qt::ItemNeverHasChildren; Qt::ItemNeverHasChildren;
} }
} }
@ -145,6 +145,12 @@ namespace Arc {
void Model::setDir(Dir *dir) { void Model::setDir(Dir *dir) {
if(dir != m_dir) { if(dir != m_dir) {
emit layoutAboutToBeChanged();
for(int row = 0, rows = rowCount(); row < rows; row++) {
for(int col = 0, cols = columnCount(); col < cols; col++) {
changePersistentIndex(index(row, col), QModelIndex{});
}
}
m_dir = dir; m_dir = dir;
emit layoutChanged(); emit layoutChanged();
emit dirChanged(dir); emit dirChanged(dir);