diff options
| author | Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> | 2025-02-02 11:07:45 +0200 |
|---|---|---|
| committer | Tomi Valkeinen <tomi.valkeinen@ideasonboard.com> | 2025-02-05 11:29:38 +0200 |
| commit | 6048b54c35905abbedf8b2f606795ff99444237c (patch) | |
| tree | e0cbdb4efc1aaf50971f0f8186577aaf81dc2248 | |
| parent | 19a33e95ba0c87634a7b4ed220b3052326cff114 (diff) | |
testpat: fix exception throwing
| -rw-r--r-- | kms++util/src/testpat.cpp | 15 |
1 files changed, 14 insertions, 1 deletions
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<std::exception_ptr> 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 |
