Bladeren bron

修复专家数据不全时,权重计算时的crash。

Ulric 10 maanden geleden
bovenliggende
commit
dd0640352d
1 gewijzigde bestanden met toevoegingen van 23 en 19 verwijderingen
  1. 23 19
      QFD/common/DataEvaluator.cpp

+ 23 - 19
QFD/common/DataEvaluator.cpp

@@ -102,16 +102,20 @@ bool DataEvaluator::evaluateWeightFromExpert()
                     for (int j = 0; j < subNodes.size(); j++) {
                         QString abs = subNodes[j].name;
                         for (int k = 0; k < subNodes.size(); k++) {
-                            QString ord = subNodes[k].name;
-                            QString key = abs + "-" + ord;
-                            double v;
-                            QStringList nodeValue = nodeData[expertId][key]->nodeValue.split("/");
-                            if (nodeValue.size() == 1) {
-                                //                                v = nodeValue[0].toDouble();
-                                v = 1.0 / nodeValue[0].toDouble();
-                            } else {
-                                //                                v = nodeValue[0].toDouble() / nodeValue[1].toDouble();
-                                v = nodeValue[1].toDouble();
+                            QString ord          = subNodes[k].name;
+                            QString key          = abs + "-" + ord;
+                            double v             = 1;
+                            NodeMatrixInfo *info = nodeData[expertId][key];
+                            if (info != nullptr) {
+                                QStringList nodeValue = info->nodeValue.split("/");
+                                if (nodeValue.size() == 1) {
+                                    //                                v = nodeValue[0].toDouble();
+                                    v = 1.0 / nodeValue[0].toDouble();
+                                } else {
+                                    //                                v = nodeValue[0].toDouble() /
+                                    //                                nodeValue[1].toDouble();
+                                    v = nodeValue[1].toDouble();
+                                }
                             }
                             nxnValus.append(v);
                         }
@@ -156,12 +160,15 @@ bool DataEvaluator::evaluateWeightFromExpert()
         for (QString key : nodeData.values().first().keys()) {
             double sum = 0;
             for (QString expertId : nodeData.keys()) {
-                double v;
-                QStringList nodeValue = nodeData[expertId][key]->nodeValue.split("/");
-                if (nodeValue.size() == 1) {
-                    v = nodeValue[0].toDouble();
-                } else {
-                    v = nodeValue[0].toDouble() / nodeValue[1].toDouble();
+                double v             = 1;
+                NodeMatrixInfo *info = nodeData[expertId][key];
+                if (info != nullptr) {
+                    QStringList nodeValue = info->nodeValue.split("/");
+                    if (nodeValue.size() == 1) {
+                        v = nodeValue[0].toDouble();
+                    } else {
+                        v = nodeValue[0].toDouble() / nodeValue[1].toDouble();
+                    }
                 }
                 sum += v * config[expertId];
             }
@@ -197,16 +204,13 @@ bool DataEvaluator::evaluateWeightFromExpert()
             }
         }
     }
-
     QStringList valueList;
     for (QString key : indexWeights.keys()) {
         valueList.append(QString("%1:%2").arg(key).arg(indexWeights[key]));
     }
     QString valueStr = valueList.join(";");
-
     bool ret = MindWeightService().saveUniqueWeightData(m_process.projectId, m_process.indexType, m_process.dSource,
                                                         algorithm, valueStr);
-
     return ret;
 }