From f54e76e6bf9aba862408da434e6e64787b86bbd6 Mon Sep 17 00:00:00 2001 From: AliceMazzoleni99 Date: Mon, 18 Aug 2025 11:02:05 +0200 Subject: [PATCH] view is only allowed on l-value frame (#220) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Vadym accidentally called view() directly on an R-value frame, which leads to a dangling view pointer. Adjusted code such that compiler throws an error if called on an R-value frame. Co-authored-by: Erik Fröjdh --- include/aare/Frame.hpp | 2 +- src/ClusterFinderMT.test.cpp | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/include/aare/Frame.hpp b/include/aare/Frame.hpp index 27a2a4a..16e9f44 100644 --- a/include/aare/Frame.hpp +++ b/include/aare/Frame.hpp @@ -105,7 +105,7 @@ class Frame { * @tparam T type of the pixels * @return NDView */ - template NDView view() { + template NDView view() & { std::array shape = {static_cast(m_rows), static_cast(m_cols)}; T *data = reinterpret_cast(m_data); diff --git a/src/ClusterFinderMT.test.cpp b/src/ClusterFinderMT.test.cpp index 7012705..0794687 100644 --- a/src/ClusterFinderMT.test.cpp +++ b/src/ClusterFinderMT.test.cpp @@ -57,6 +57,7 @@ class ClusterFinderMTWrapper size_t m_sink_size() const { return this->m_sink.sizeGuess(); } }; + TEST_CASE("multithreaded cluster finder", "[.with-data]") { auto fpath = test_data_path() / "raw/moench03/cu_half_speed_master_4.json"; @@ -81,7 +82,8 @@ TEST_CASE("multithreaded cluster finder", "[.with-data]") { CHECK(cf.m_input_queues_are_empty() == true); for (size_t i = 0; i < n_frames_pd; ++i) { - cf.find_clusters(file.read_frame().view()); + auto frame = file.read_frame(); + cf.find_clusters(frame.view()); } cf.stop();