修正创建LeafLayer引用组合元素后,无法析构的问题
parent
214fa0f82f
commit
aa9743d4e7
|
@ -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();
|
||||||
|
|
Loading…
Reference in New Issue