Browse Source

修复新建项目方案页面的 crash

chengxr 1 year ago
parent
commit
ff6fc6bcbb

+ 10 - 0
QFD/shemeFlow/FlowGraphNodeWidget.cpp

@@ -230,6 +230,11 @@ bool FlowGraphCommonNodeWidget::isOptional() const
 void FlowGraphCommonNodeWidget::slotAlgComboChanged(int index)
 {
     QList<SchemePlanManager::Algorithm> list = optionalAlgs();
+
+    if (list.size() <= index) {
+        return;
+    }
+
     if (m_process.algorithm == list.at(index)) {
         return;
     }
@@ -244,6 +249,11 @@ void FlowGraphCommonNodeWidget::slotAlgComboChanged(int index)
 void FlowGraphCommonNodeWidget::slotDataComboChanged(int index)
 {
     QList<SchemePlanManager::SchemeDataSource> list = optionaldSource();
+
+    if (list.size() <= index) {
+        return;
+    }
+
     if (m_process.dSource == list.at(index)) {
         return;
     }

+ 2 - 2
QFD/widgets/DataCollectionWidget.cpp

@@ -319,8 +319,8 @@ void DataCollectionWidget::slotConfigSelected(UserConfig *config)
     DataTableWidget *table = (DataTableWidget *)m_tab->currentWidget();
     QString indexName      = ProjectManager::nameOfIndexType((ProjectManager::IndexType)table->process().indexType);
 
-    MindEvaluation *eval = new MindEvaluation(table->mind1(), MindEvaluation::NoMerge, indexName,
-                                              table->process().dSource == SchemePlanManager::FromExpert);
+    MindEvaluation *eval =
+            new MindEvaluation(table->mind1(), MindEvaluation::NoMerge, indexName, table->process().dSource);
     eval->updateSeqNodes();
     eval->computeWeights();
 

+ 6 - 3
QFD/widgets/SchemePlanWidget.cpp

@@ -83,8 +83,12 @@ QList<SchemePlanManager::SchemeProcessInfo> SchemePlanWidget::templateSchemes(in
         process.indexType = indexType;
         process.type      = types[i];
         process.step      = i;
-        process.dSource   = SchemePlanManager::processOptionalDataSource(process).first();
-        process.algorithm = SchemePlanManager::processOptionalAlgorithms(process).first();
+
+        QList<SchemePlanManager::SchemeDataSource> data = SchemePlanManager::processOptionalDataSource(process);
+        process.dSource                                 = data.size() > 0 ? data.first() : SchemePlanManager::NoData;
+
+        QList<SchemePlanManager::Algorithm> algs = SchemePlanManager::processOptionalAlgorithms(process);
+        process.algorithm                        = algs.size() > 0 ? algs.first() : SchemePlanManager::NoAlg;
         schemes.append(process);
     }
 
@@ -108,7 +112,6 @@ void SchemePlanWidget::setupTabWidget()
         if (ret) {
             m->loadSchemes(schemes);
         }
-
         ProjectManager::IndexType t = (ProjectManager::IndexType)i;
         QString s                   = ProjectManager::nameOfIndexType(t);
         m_tab->addTab(m, s);