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