修复空story崩溃问题

This commit is contained in:
codeboss 2025-05-17 22:40:43 +08:00
parent 5a4369d7cc
commit c58b022b21
2 changed files with 18 additions and 15 deletions

View File

@ -3,7 +3,7 @@
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
<LocalDebuggerWorkingDirectory>$(SolutionDir)$(Platform)\$(Configuration)\</LocalDebuggerWorkingDirectory> <LocalDebuggerWorkingDirectory>$(SolutionDir)$(Platform)\$(Configuration)\</LocalDebuggerWorkingDirectory>
<DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor> <DebuggerFlavor>WindowsLocalDebugger</DebuggerFlavor>
<LocalDebuggerCommandArguments>--path "E:\novel-set" --dest F:\novelout</LocalDebuggerCommandArguments> <LocalDebuggerCommandArguments>--path "E:\CustomNovels\科学+修仙+创造世界" --dest F:\novelout</LocalDebuggerCommandArguments>
</PropertyGroup> </PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'"> <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
<LocalDebuggerCommandArguments>--path "D:\Projects\Cpp\WsNovelParser\x64\test_file" --dest E:\</LocalDebuggerCommandArguments> <LocalDebuggerCommandArguments>--path "D:\Projects\Cpp\WsNovelParser\x64\test_file" --dest E:\</LocalDebuggerCommandArguments>

View File

@ -393,12 +393,15 @@ std::shared_ptr<FragmentNode> FragmentLayerCheck::_sets_fill(std::shared_ptr<con
auto ptr = _sets_fill(nis); auto ptr = _sets_fill(nis);
if (ptr) list << ptr; if (ptr) list << ptr;
} }
for (auto nitr = ++list.begin(); nitr != list.end(); nitr++)
(*(nitr-1))->appendNext(*nitr);
if (list.size()) if (list.size()) {
for (auto nitr = ++list.begin(); nitr != list.end(); nitr++) {
auto prev = *(nitr - 1);
prev->appendNext(*nitr);
}
this->_story_start << list.first(); this->_story_start << list.first();
} }
}
break; break;
default: default:
for (auto nis : node->children()) for (auto nis : node->children())
@ -427,7 +430,6 @@ void FragmentLayerCheck::node_relayer(std::shared_ptr<FragmentNode> node, int cu
for (auto nis : node->referNodes()) for (auto nis : node->referNodes())
node_relayer(nis, curr_num + 1); node_relayer(nis, curr_num + 1);
} }
qDebug() << node->bind()->element()->signature() << node->layerNumber();
} }
@ -455,6 +457,7 @@ void FragmentLayerCheck::story_layer_check(std::shared_ptr<const ast_gen::Elemen
std::copy_if(fragms_list.begin(), fragms_list.end(), std::back_inserter(real_elms), std::copy_if(fragms_list.begin(), fragms_list.end(), std::back_inserter(real_elms),
[](std::shared_ptr<const ast_gen::ElementAccess> ins) { return ins->element()->typeMark() == (int) NovelNode::FragmentSlice; }); [](std::shared_ptr<const ast_gen::ElementAccess> ins) { return ins->element()->typeMark() == (int) NovelNode::FragmentSlice; });
if (real_elms.size())
for (auto curr = ++real_elms.begin(); curr != real_elms.end(); ++curr) { for (auto curr = ++real_elms.begin(); curr != real_elms.end(); ++curr) {
auto prev_it = curr - 1; auto prev_it = curr - 1;
auto curr_it = curr; auto curr_it = curr;
@ -480,7 +483,7 @@ void FragmentLayerCheck::sibling_element_compair(const QString& story, std::shar
return; return;
auto max_e0 = *std::max_element(prev_childs.begin(), prev_childs.end(), auto max_e0 = *std::max_element(prev_childs.begin(), prev_childs.end(),
[](std::shared_ptr<const FragmentNode> a, std::shared_ptr<const FragmentNode> b){ [](std::shared_ptr<const FragmentNode> a, std::shared_ptr<const FragmentNode> b) {
return a->layerNumber() < b->layerNumber(); return a->layerNumber() < b->layerNumber();
}); });
auto min_e1 = *std::min_element(curr_childs.begin(), curr_childs.end(), auto min_e1 = *std::min_element(curr_childs.begin(), curr_childs.end(),