From c0b3ea28eafc4adf7eb672e39bdc8473d04fdd91 Mon Sep 17 00:00:00 2001 From: Horror Proton <107091537+horror-proton@users.noreply.github.com> Date: Sat, 8 Jun 2024 22:38:14 +0800 Subject: [PATCH] fix: fix coredump caused by screencap failure --- src/MaaCore/Controller/AdbController.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/MaaCore/Controller/AdbController.cpp b/src/MaaCore/Controller/AdbController.cpp index a49eb521e7..bc66e28004 100644 --- a/src/MaaCore/Controller/AdbController.cpp +++ b/src/MaaCore/Controller/AdbController.cpp @@ -577,6 +577,9 @@ bool asst::AdbController::screencap(cv::Mat& image_payload, bool allow_reconnect if (m_screencap_times > 9) { // 每 10 次截图计算一次平均耗时 m_screencap_times = 0; auto filtered_cost = m_screencap_cost | views::filter([](auto num) { return num > 0; }); + if (filtered_cost.empty()) { + return screencap_ret; + } // 过滤后的有效截图用时次数 auto filtered_count = m_screencap_cost.size() - ranges::count(m_screencap_cost, -1); auto [screencap_cost_min, screencap_cost_max] = ranges::minmax(filtered_cost);