fix:修复dataPanle配置时,选择多个数据源(多条曲线)造成的程序崩溃(由于引用了局部变量的地址)问题
This commit is contained in:
parent
6386d00229
commit
b02902a0ef
|
|
@ -99,11 +99,18 @@ protected:
|
|||
{
|
||||
QColor color;
|
||||
RealTimeDataType dataType;
|
||||
//QCPGraph* qGraph = nullptr;
|
||||
//QCPGraph* qGraph;
|
||||
QPointer<QCPGraph> qGraph;
|
||||
|
||||
QString dataID;
|
||||
QString synchronizeTagging; //同步配置数据时的标记,new、update两种,没有的就是要被删除
|
||||
|
||||
Graph()
|
||||
{
|
||||
dataID = "";
|
||||
//qGraph = nullptr;
|
||||
synchronizeTagging = "noTagging";
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -145,9 +145,16 @@ void dpConfigurationDialog::copyModelData(QStandardItemModel* sourceModel, QStan
|
|||
if(item)
|
||||
{
|
||||
QStandardItem* newItem = new QStandardItem(item->text());
|
||||
newItem->setData(item->data(Qt::DecorationRole), Qt::DecorationRole);
|
||||
QString strTag = item->data(Qt::UserRole + itemRole_tag).toString();
|
||||
RealTimeDataType dataType = (RealTimeDataType)item->data(Qt::UserRole + itemRole_dataType).toInt();
|
||||
newItem->setData(dataType, Qt::UserRole + itemRole_dataType);
|
||||
if(strTag == "point")
|
||||
{
|
||||
newItem->setData(item->data(Qt::DecorationRole), Qt::DecorationRole);
|
||||
newItem->setData(item->data(Qt::UserRole + itemRole_stationID), Qt::UserRole + itemRole_stationID);
|
||||
newItem->setData(item->data(Qt::UserRole + itemRole_componentID), Qt::UserRole + itemRole_componentID);
|
||||
newItem->setData(item->data(Qt::UserRole + itemRole_pointID), Qt::UserRole + itemRole_pointID);
|
||||
}
|
||||
itemList.push_back(newItem);
|
||||
}
|
||||
}
|
||||
|
|
@ -521,6 +528,7 @@ void dpConfigurationDialog::onItemClicked_dataSource(const QModelIndex& index)
|
|||
{
|
||||
QStandardItem* newItem = new QStandardItem(strText);
|
||||
newItem->setEditable(false);
|
||||
newItem->setData(item->data(Qt::UserRole + itemRole_tag), Qt::UserRole + itemRole_tag);
|
||||
newItem->setData(item->data(Qt::UserRole + itemRole_stationID), Qt::UserRole + itemRole_stationID);
|
||||
newItem->setData(item->data(Qt::UserRole + itemRole_componentID), Qt::UserRole + itemRole_componentID);
|
||||
newItem->setData(item->data(Qt::UserRole + itemRole_pointID), Qt::UserRole + itemRole_pointID);
|
||||
|
|
|
|||
|
|
@ -355,7 +355,7 @@ void dpLineChart::synchronizeConfigData(const configurationResults& cfg)
|
|||
axis.setQCPAxis(pAxis, false);
|
||||
}
|
||||
m_axes.append(axis);
|
||||
axesMap.insert(axis._cfg.dataType, &axis); //临时变量axesMap通过做更新
|
||||
axesMap.insert(axis._cfg.dataType, &m_axes.last()); //临时变量axesMap通过做更新,此处不要直接使用&axis,因为axis是局部变量,地址会被自动释放,造成堆错误
|
||||
#endif
|
||||
}
|
||||
}
|
||||
|
|
@ -370,6 +370,7 @@ void dpLineChart::synchronizeConfigData(const configurationResults& cfg)
|
|||
QString stationID = cfg.m_pModel_dataSource->item(i, 0)->data(Qt::UserRole + itemRole_stationID).toString();
|
||||
QString compoentID = cfg.m_pModel_dataSource->item(i, 0)->data(Qt::UserRole + itemRole_componentID).toString();
|
||||
QString pointID = cfg.m_pModel_dataSource->item(i, 0)->data(Qt::UserRole + itemRole_pointID).toString();
|
||||
|
||||
QString graphID = stationID + "-" + compoentID + "-" + pointID;
|
||||
if(!m_graphs.contains(graphID)) //新增数据
|
||||
{
|
||||
|
|
@ -416,6 +417,8 @@ void dpLineChart::synchronizeConfigData(const configurationResults& cfg)
|
|||
qWarning() << "Failed to remove graph:" << key;
|
||||
}
|
||||
|
||||
qDebug() << m_graphs.count();
|
||||
|
||||
m_updateData = true;
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue