fix part of memory leak

This commit is contained in:
baiYue 2025-07-24 10:01:31 +08:00
parent 4f3c865126
commit 42735dc4d8
5 changed files with 23 additions and 13 deletions

View File

@ -50,12 +50,10 @@ enum class ModelFunctionType //模型函数的类型
BaseModel
};
class corresbondItem //类型关联函数
{
public:
static QMap<AbstractItemType,GraphicsItemType> linkType;
static QMap<int,GraphicsItemType> typeToProGraphic;
};
extern const QMap<AbstractItemType,GraphicsItemType> linkType;
//类型转换
extern const QMap<int,GraphicsItemType> typeToProGraphic;
enum DiagramMode //组态图模式
{

View File

@ -1,8 +1,9 @@
#include "global.h"
QMap<AbstractItemType,GraphicsItemType> corresbondItem::linkType = {
const QMap<AbstractItemType,GraphicsItemType> linkType = {
{AIT_motor,GIT_itemRect},{AIT_bus,GIT_bus},
};
QMap<int,GraphicsItemType> corresbondItem::typeToProGraphic = {
//类型转换
const QMap<int,GraphicsItemType> typeToProGraphic = {
{1,GIT_bus},{3,GIT_itemRect},{8,GIT_link}
};
};

View File

@ -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 <typename T> void DiagramEditorWizard::reindexQMap(QMap<int, T> &map) {
if (map.isEmpty())
return;

View File

@ -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);

View File

@ -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;
}