From 948b3d40b730bd3ecba3e30b3c77709a4d89419f Mon Sep 17 00:00:00 2001 From: Gergely Nagy Date: Sun, 17 Jun 2018 11:03:57 +0200 Subject: [PATCH] Override onSetup when using a compatibility layer The default `onSetup` will call `.begin`, to support initializing plugins using the V1 plugins while using `KALEIDOSCOPE_INIT_PLUGINS`. However, plugins that implement a compatibility layer so that they can be used with both the new API, and with `Kaleidoscope.use()` will have a `.begin` method too. Which the default `onSetup` will call, and we'll register the compatibility layer too, in addition to the new-style event handlers. This results in many things running twice, which leads to all kinds of problems. For this reason, override `onSetup`, so that it does not call `begin`. When used with `Kaleidoscope.use()`, the plugin will still work, so compatibility is maintained. But the bug is now gone. Signed-off-by: Gergely Nagy --- src/Kaleidoscope/HostPowerManagement.h | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/Kaleidoscope/HostPowerManagement.h b/src/Kaleidoscope/HostPowerManagement.h index 01b9d4f5..72a0826f 100644 --- a/src/Kaleidoscope/HostPowerManagement.h +++ b/src/Kaleidoscope/HostPowerManagement.h @@ -41,6 +41,10 @@ class HostPowerManagement : public kaleidoscope::Plugin { EventHandlerResult beforeEachCycle(); #if KALEIDOSCOPE_ENABLE_V1_PLUGIN_API + kaleidoscope::EventHandlerResult onSetup() { + return kaleidoscope::EventHandlerResult::OK; + } + protected: void begin(); static void legacyLoopHook(bool is_post_clear);