From 42735dc4d836ca64a1df6d668b9b2af8a14ed18c Mon Sep 17 00:00:00 2001 From: baiYue Date: Thu, 24 Jul 2025 10:01:31 +0800 Subject: [PATCH] fix part of memory leak --- common/include/global.h | 10 ++++------ common/source/global.cpp | 7 ++++--- .../source/diagramEditor/diagramEditorWizard.cpp | 13 ++++++++++++- .../source/graphicsDataModel/fixedPortsModel.cpp | 2 +- source/electricElementsBox.cpp | 4 ++-- 5 files changed, 23 insertions(+), 13 deletions(-) diff --git a/common/include/global.h b/common/include/global.h index dde278b..5e26e1d 100644 --- a/common/include/global.h +++ b/common/include/global.h @@ -50,12 +50,10 @@ enum class ModelFunctionType //模型函数的类型 BaseModel }; -class corresbondItem //类型关联函数 -{ -public: - static QMap linkType; - static QMap typeToProGraphic; -}; + +extern const QMap linkType; +//类型转换 +extern const QMap typeToProGraphic; enum DiagramMode //组态图模式 { diff --git a/common/source/global.cpp b/common/source/global.cpp index 6473d39..6d6871a 100644 --- a/common/source/global.cpp +++ b/common/source/global.cpp @@ -1,8 +1,9 @@ #include "global.h" -QMap corresbondItem::linkType = { +const QMap linkType = { {AIT_motor,GIT_itemRect},{AIT_bus,GIT_bus}, }; -QMap corresbondItem::typeToProGraphic = { +//类型转换 +const QMap typeToProGraphic = { {1,GIT_bus},{3,GIT_itemRect},{8,GIT_link} - }; +}; diff --git a/diagramCavas/source/diagramEditor/diagramEditorWizard.cpp b/diagramCavas/source/diagramEditor/diagramEditorWizard.cpp index d608b55..cf39aeb 100644 --- a/diagramCavas/source/diagramEditor/diagramEditorWizard.cpp +++ b/diagramCavas/source/diagramEditor/diagramEditorWizard.cpp @@ -53,11 +53,22 @@ void DiagramEditorWizard::reOrderBus() for(int row = 0 ;row < ui->tableWidget_bus->rowCount();++row) { QTableWidgetItem* pItem = ui->tableWidget_bus->item(row,0); - pItem->setText("第"+QString::number(row)+"层"); + pItem->setText("第"+QString::number(row+1)+"层"); pItem->setData(Qt::UserRole,row); } } +void DiagramEditorWizard::generateBayPage() +{ + for(auto& busInfo:_mapBus) + { + QListWidgetItem* item = new QListWidgetItem("第"+QString::number(busInfo.nIndex+1)+"层"); + item->setData(Qt::UserRole,busInfo.nIndex); + ui->listWidget_bay->addItem(item); + + } +} + template void DiagramEditorWizard::reindexQMap(QMap &map) { if (map.isEmpty()) return; diff --git a/diagramCavas/source/graphicsDataModel/fixedPortsModel.cpp b/diagramCavas/source/graphicsDataModel/fixedPortsModel.cpp index 161aef1..dc0a080 100644 --- a/diagramCavas/source/graphicsDataModel/fixedPortsModel.cpp +++ b/diagramCavas/source/graphicsDataModel/fixedPortsModel.cpp @@ -217,7 +217,7 @@ BaseProperty* FixedPortsModel::addNodeData(QUuid id,int type,QString name,QStrin item->setUuid(id); item->setModelName(modelName); item->setType(type); - GraphicsItemType localType = corresbondItem::typeToProGraphic[type]; //将通用类型转换为工程模图元 + GraphicsItemType localType = typeToProGraphic[type]; //将通用类型转换为工程模图元 item->setGraphicsType(localType); item->setTag(name); item->setName(name); diff --git a/source/electricElementsBox.cpp b/source/electricElementsBox.cpp index 8dceaff..fb3d4ff 100644 --- a/source/electricElementsBox.cpp +++ b/source/electricElementsBox.cpp @@ -32,7 +32,7 @@ void ElectricElementsBox::addPanelItems(const QString& sPanel) for(auto &model:_modelInfo) { - GraphicsItemType localType = corresbondItem::linkType[(AbstractItemType)model.modelType]; + GraphicsItemType localType = linkType[(AbstractItemType)model.modelType]; model.modelType = localType; //转换图元类别,从字典表转到内部类别 } @@ -58,7 +58,7 @@ void ElectricElementsBox::updateModelList() { for(auto &model:_modelInfo) { - GraphicsItemType localType = corresbondItem::linkType[(AbstractItemType)model.modelType]; + GraphicsItemType localType = linkType[(AbstractItemType)model.modelType]; model.modelType = localType; }