Skip to content

Commit

Permalink
修复FluTree::setDataSource内存泄漏问题
Browse files Browse the repository at this point in the history
  • Loading branch information
Polaris-Night committed Mar 3, 2025
1 parent 882cc89 commit aa2334e
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/FluTreeModel.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -107,15 +107,15 @@ void FluTreeModel::checkRow(int row, bool checked) {
void FluTreeModel::setDataSource(QList<QMap<QString, QVariant>> data) {
_dataSource.clear();
if (_root) {
delete _root;
_root->deleteLater();
_root = nullptr;
}
_root = new FluTreeNode(this);
std::reverse(data.begin(), data.end());
while (data.count() > 0) {
auto item = data.at(data.count() - 1);
data.pop_back();
auto *node = new FluTreeNode(this);
auto *node = new FluTreeNode(_root);
node->_depth = item.value("__depth").toInt();
node->_parent = item.value("__parent").value<FluTreeNode *>();
node->_data = item;
Expand Down
1 change: 1 addition & 0 deletions src/Qt5/imports/FluentUI/Controls/FluTreeView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ Rectangle {
}
return {}
}
active: rowModel !== undefined && rowModel !== null
sourceComponent: {
if(column === 0)
return com_column
Expand Down
1 change: 1 addition & 0 deletions src/Qt6/imports/FluentUI/Controls/FluTreeView.qml
Original file line number Diff line number Diff line change
Expand Up @@ -474,6 +474,7 @@ Rectangle {
}
return {}
}
active: rowModel !== undefined && rowModel !== null
sourceComponent: {
if(column === 0)
return com_column
Expand Down

0 comments on commit aa2334e

Please sign in to comment.