Merge pull request #593 from Polaris-Night/main

修复FluTreeModel::setDataSource内存泄漏问题
This commit is contained in:
zhuzichu 2025-03-08 14:49:26 +08:00 committed by GitHub
commit 1990203f3b
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 4 additions and 2 deletions

View File

@ -107,7 +107,7 @@ void FluTreeModel::checkRow(int row, bool checked) {
void FluTreeModel::setDataSource(QList<QMap<QString, QVariant>> data) { void FluTreeModel::setDataSource(QList<QMap<QString, QVariant>> data) {
_dataSource.clear(); _dataSource.clear();
if (_root) { if (_root) {
delete _root; _root->deleteLater();
_root = nullptr; _root = nullptr;
} }
_root = new FluTreeNode(this); _root = new FluTreeNode(this);
@ -115,7 +115,7 @@ void FluTreeModel::setDataSource(QList<QMap<QString, QVariant>> data) {
while (data.count() > 0) { while (data.count() > 0) {
auto item = data.at(data.count() - 1); auto item = data.at(data.count() - 1);
data.pop_back(); data.pop_back();
auto *node = new FluTreeNode(this); auto *node = new FluTreeNode(_root);
node->_depth = item.value("__depth").toInt(); node->_depth = item.value("__depth").toInt();
node->_parent = item.value("__parent").value<FluTreeNode *>(); node->_parent = item.value("__parent").value<FluTreeNode *>();
node->_data = item; node->_data = item;

View File

@ -474,6 +474,7 @@ Rectangle {
} }
return {} return {}
} }
active: rowModel !== undefined && rowModel !== null
sourceComponent: { sourceComponent: {
if(column === 0) if(column === 0)
return com_column return com_column

View File

@ -474,6 +474,7 @@ Rectangle {
} }
return {} return {}
} }
active: rowModel !== undefined && rowModel !== null
sourceComponent: { sourceComponent: {
if(column === 0) if(column === 0)
return com_column return com_column