Skip to content

Commit

Permalink
Fix update folder node failure.
Browse files Browse the repository at this point in the history
And imporve the refresh of folder.

Issue Description
If you create new folder in a folder which has no other folder,then file browser won't refresh properly.
This commit has solved this issue.
  • Loading branch information
Abel You committed Jan 18, 2025
1 parent f012b88 commit 0693939
Showing 1 changed file with 23 additions and 4 deletions.
27 changes: 23 additions & 4 deletions toonz/sources/toonz/filebrowsermodel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1295,11 +1295,30 @@ void DvDirModel::onFolderChanged(const TFilePath &path) { refreshFolder(path); }
void DvDirModel::refresh(const QModelIndex &index) {
if (!index.isValid()) return;
DvDirModelNode *node = getNode(index);
if (!node || node->getChildCount() < 1) return;
if (!node) return;

emit layoutAboutToBeChanged();
emit beginRemoveRows(index, 0, node->getChildCount() - 1);
node->refreshChildren();
emit endRemoveRows();

int oldChildren = node->getChildCount();
if (oldChildren > 0) {
emit beginRemoveRows(index, 0, oldChildren - 1);
node->refreshChildren();
emit endRemoveRows();
}
else if (oldChildren == 0) {
node->refreshChildren();
}
else {
emit layoutChanged();
return;
}

int newChildren = node->getChildCount();
if(newChildren > 0){
emit beginInsertRows(index, 0, newChildren - 1);
emit endInsertRows();
}

emit layoutChanged();
}

Expand Down

0 comments on commit 0693939

Please sign in to comment.