From a7ebfc68859c4f86449d86195714b53f2e48839a Mon Sep 17 00:00:00 2001 From: Hans-Kristian Arntzen Date: Sun, 19 Nov 2023 22:01:17 +0100 Subject: [PATCH] Use proper capturing technique. --- application/events/application_wsi.cpp | 7 ++++--- application/events/application_wsi.hpp | 2 +- 2 files changed, 5 insertions(+), 4 deletions(-) diff --git a/application/events/application_wsi.cpp b/application/events/application_wsi.cpp index 586d6cf5..fb8c9376 100644 --- a/application/events/application_wsi.cpp +++ b/application/events/application_wsi.cpp @@ -98,15 +98,15 @@ void GraniteWSIPlatform::dispatch_template_filter(const T &t) } template -void GraniteWSIPlatform::dispatch_or_defer(const Func &func) +void GraniteWSIPlatform::dispatch_or_defer(Func &&func) { if (in_async_input) - captured.emplace_back(std::move(func)); + captured.emplace_back(std::forward(func)); else func(); } -#define WORK(work) dispatch_or_defer([this, &e]() { work; }) +#define WORK(work) dispatch_or_defer([this, e]() { work; }) void GraniteWSIPlatform::dispatch(const TouchDownEvent &e) { @@ -180,6 +180,7 @@ void GraniteWSIPlatform::end_async_input_handling() void GraniteWSIPlatform::flush_deferred_input_events() { + VK_ASSERT(!in_async_input); for (auto &func : captured) func(); captured.clear(); diff --git a/application/events/application_wsi.hpp b/application/events/application_wsi.hpp index 76e7c5f3..356864ac 100644 --- a/application/events/application_wsi.hpp +++ b/application/events/application_wsi.hpp @@ -73,7 +73,7 @@ class GraniteWSIPlatform : public Vulkan::WSIPlatform, private InputTrackerHandl template void dispatch_template(const T &t); template - void dispatch_or_defer(const Func &func); + void dispatch_or_defer(Func &&func); bool in_async_input = false; std::vector> captured;