From 6048b54c35905abbedf8b2f606795ff99444237c Mon Sep 17 00:00:00 2001 From: Tomi Valkeinen Date: Sun, 2 Feb 2025 11:07:45 +0200 Subject: testpat: fix exception throwing --- kms++util/src/testpat.cpp | 15 ++++++++++++++- 1 file changed, 14 insertions(+), 1 deletion(-) (limited to 'kms++util') diff --git a/kms++util/src/testpat.cpp b/kms++util/src/testpat.cpp index 1102588..7699243 100644 --- a/kms++util/src/testpat.cpp +++ b/kms++util/src/testpat.cpp @@ -180,6 +180,8 @@ static void draw_test_pattern_impl(IFramebuffer& fb, YUVType yuvt) unsigned part = (fb.height() / num_threads) & ~1; + std::vector errors(num_threads); + for (unsigned n = 0; n < num_threads; ++n) { unsigned start = n * part; unsigned end = start + part; @@ -187,11 +189,22 @@ static void draw_test_pattern_impl(IFramebuffer& fb, YUVType yuvt) if (n == num_threads - 1) end = fb.height(); - workers.push_back(thread([&fb, start, end, yuvt]() { draw_test_pattern_part(fb, start, end, yuvt); })); + workers.push_back(thread([&fb, start, end, yuvt, &error = errors[n]]() { + try { + draw_test_pattern_part(fb, start, end, yuvt); + } catch(...) { + error = std::current_exception(); + } + })); } for (thread& t : workers) t.join(); + + auto i = std::find_if(errors.begin(), errors.end(), [](auto& e) { return e != nullptr; }); + if (i != errors.end()) + std::rethrow_exception(*i); + #else draw_test_pattern_part(fb, 0, fb.height(), yuvt); #endif -- cgit v1.2.3