修正创建LeafLayer引用组合元素后,无法析构的问题

dev-wuyize
karlis 2023-03-23 15:59:33 +08:00
parent 214fa0f82f
commit aa9743d4e7
1 changed files with 10 additions and 5 deletions

View File

@ -59,14 +59,19 @@ void LayerTreeWidget::popMenu(const QPoint &pos)
auto dialog = new LayerCreateWidget(elementManager, dynamic_cast<FolderLayerWrapper*>(layer), this); auto dialog = new LayerCreateWidget(elementManager, dynamic_cast<FolderLayerWrapper*>(layer), this);
connect(dialog, &LayerCreateWidget::LayerInfoReturned, this, [this, layer](QJsonObject jsonObj) { connect(dialog, &LayerCreateWidget::LayerInfoReturned, this, [this, layer](QJsonObject jsonObj) {
auto folderLayer = dynamic_cast<FolderLayerWrapper*>(layer); auto folderLayer = dynamic_cast<FolderLayerWrapper*>(layer);
LayerWrapper* newLayer; std::shared_ptr<LayerWrapper> newLayer;
qDebug() << this->elementManager; qDebug() << this->elementManager;
if(jsonObj.value("is-folder").toBool()) if (jsonObj.value("is-folder").toBool())
newLayer = new FolderLayerWrapper(jsonObj, this->elementManager, folderLayer); {
newLayer = std::make_shared<FolderLayerWrapper>(jsonObj, this->elementManager, folderLayer);
folderLayer->addChild(newLayer);
}
else else
newLayer = new LeafLayerWrapper(jsonObj, this->elementManager, folderLayer); {
newLayer = std::make_shared<LeafLayerWrapper>(jsonObj, this->elementManager, folderLayer);
folderLayer->addChild(newLayer);
}
folderLayer->addChild(std::shared_ptr<LayerWrapper>(newLayer));
folderLayer->qTreeWidgetItem->addChild(newLayer->getQTreeItem()); folderLayer->qTreeWidgetItem->addChild(newLayer->getQTreeItem());
qDebug() << jsonObj<<"----------------------"; qDebug() << jsonObj<<"----------------------";
emit triggerCentralRefresh(); emit triggerCentralRefresh();