Skip to content

Commit 7a8bf03

Browse files
authored
fix: batch OCR crash when inline sub_name conflicts with pipeline node (#1280)
1 parent 071ac3d commit 7a8bf03

1 file changed

Lines changed: 5 additions & 15 deletions

File tree

source/MaaFramework/Task/PipelineTask.cpp

Lines changed: 5 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -358,23 +358,11 @@ std::optional<PipelineTask::BatchOCRPlan> PipelineTask::prepare_batch_ocr(const
358358
collect_ocr_from_reco(ctx, data.name, data.reco_type, data.reco_param);
359359
}
360360

361-
if (ctx.plan.node_names.size() < 2) {
362-
LogDebug << "batch OCR not needed, eligible OCR nodes < 2" << VAR(ctx.plan.node_names.size());
361+
if (ctx.plan.entries.size() < 2) {
362+
LogDebug << "batch OCR not needed, eligible OCR nodes < 2" << VAR(ctx.plan.entries.size());
363363
return std::nullopt;
364364
}
365365

366-
for (const auto& name : ctx.plan.node_names) {
367-
auto node_opt = context_->get_pipeline_data(name);
368-
if (!node_opt) {
369-
continue;
370-
}
371-
ctx.plan.entries.emplace_back(
372-
BatchOCREntry {
373-
.name = name,
374-
.param = std::get<MAA_VISION_NS::OCRerParam>(node_opt->reco_param),
375-
});
376-
}
377-
378366
LogInfo << "prepared batch OCR plan" << VAR(ctx.plan.node_names) << VAR(ctx.plan.model);
379367
return ctx.plan;
380368
}
@@ -409,7 +397,9 @@ void PipelineTask::try_add_ocr_node(OCRCollectContext& ctx, const std::string& n
409397
return;
410398
}
411399

412-
ctx.plan.node_names.emplace(name);
400+
if (ctx.plan.node_names.emplace(name).second) {
401+
ctx.plan.entries.emplace_back(BatchOCREntry { .name = name, .param = param });
402+
}
413403
}
414404

415405
void PipelineTask::collect_ocr_from_reco(

0 commit comments

Comments
 (0)