From 1e6ff421944132ba8dd5a6d041af6a666539e33b Mon Sep 17 00:00:00 2001 From: Joshua Villasenor Date: Wed, 26 Jan 2022 10:57:10 -0800 Subject: [PATCH] Resolve event crasher. --- examples/placeholder/linux/include/TestCommand.h | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/examples/placeholder/linux/include/TestCommand.h b/examples/placeholder/linux/include/TestCommand.h index 40e111fc3cd737..25530628bf04ae 100644 --- a/examples/placeholder/linux/include/TestCommand.h +++ b/examples/placeholder/linux/include/TestCommand.h @@ -66,6 +66,14 @@ class TestCommand : public PICSChecker, public LogCommands return CHIP_NO_ERROR; } + static void ScheduleNextTest(intptr_t context) + { + TestCommand * command = reinterpret_cast(context); + command->isRunning = true; + command->NextTest(); + chip::DeviceLayer::PlatformMgr().RemoveEventHandler(OnPlatformEvent, context); + } + CHIP_ERROR WaitForCommissioning() { isRunning = false; @@ -78,11 +86,7 @@ class TestCommand : public PICSChecker, public LogCommands { case chip::DeviceLayer::DeviceEventType::kCommissioningComplete: ChipLogProgress(chipTool, "Commissioning complete"); - - TestCommand * command = reinterpret_cast(arg); - command->isRunning = true; - command->NextTest(); - chip::DeviceLayer::PlatformMgr().RemoveEventHandler(OnPlatformEvent, arg); + chip::DeviceLayer::PlatformMgr().ScheduleWork(ScheduleNextTest, arg); break; } }