From df2d728af73b80ccab98d0fedc14266a976a715d Mon Sep 17 00:00:00 2001 From: Cameron Gutman Date: Tue, 16 Jan 2024 18:28:45 -0600 Subject: [PATCH] Fix plane_it_t skipping the last entry when iterating --- src/platform/linux/kmsgrab.cpp | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/platform/linux/kmsgrab.cpp b/src/platform/linux/kmsgrab.cpp index 492907c7..3ea4eec8 100644 --- a/src/platform/linux/kmsgrab.cpp +++ b/src/platform/linux/kmsgrab.cpp @@ -186,14 +186,14 @@ namespace platf { public: plane_it_t(int fd, std::uint32_t *plane_p, std::uint32_t *end): fd { fd }, plane_p { plane_p }, end { end } { - inc(); + load_next_valid_plane(); } plane_it_t(int fd, std::uint32_t *end): fd { fd }, plane_p { end }, end { end } {} void - inc() { + load_next_valid_plane() { this->plane.reset(); for (; plane_p != end; ++plane_p) { @@ -204,13 +204,16 @@ namespace platf { } this->plane = util::make_shared(plane.release()); - - // One last increment - ++plane_p; break; } } + void + inc() { + ++plane_p; + load_next_valid_plane(); + } + bool eq(const plane_it_t &other) const { return plane_p == other.plane_p;