fix.在因配置错误导致的指针失效时向日志输出信息

This commit is contained in:
zzyyyl
2022-05-04 14:19:03 +08:00
parent a74ceac116
commit e5fce05360
2 changed files with 12 additions and 2 deletions

View File

@@ -87,9 +87,14 @@ bool ProcessTask::_run()
Rect rect;
std::shared_ptr<TaskInfo> cur_task_ptr = nullptr;
auto front_task_ptr = Task.get(m_cur_tasks_name.front());
// 可能有配置错误,导致不存在对应的任务
if (front_task_ptr == nullptr) {
Log.error("Invalid task", m_cur_tasks_name.front());
return false;
}
// 如果第一个任务是JustReturn的那就没必要再截图并计算了
if (auto front_task_ptr = Task.get(m_cur_tasks_name.front());
front_task_ptr->algorithm == AlgorithmType::JustReturn) {
if (front_task_ptr->algorithm == AlgorithmType::JustReturn) {
cur_task_ptr = front_task_ptr;
}
else {

View File

@@ -98,6 +98,11 @@ bool asst::ProcessTaskImageAnalyzer::analyze()
for (const std::string& task_name : m_tasks_name) {
auto task_ptr = Task.get(task_name);
// 可能有配置错误,导致不存在对应的任务
if (task_ptr == nullptr) {
Log.error("Invalid task", task_name);
continue;
}
switch (task_ptr->algorithm) {
case AlgorithmType::JustReturn: