From 15430728f100371208bc1ef50b877fd887ca22ca Mon Sep 17 00:00:00 2001 From: "Josh V [Apple]" Date: Wed, 26 Jan 2022 18:36:55 -0800 Subject: [PATCH] Resolve event crasher. (#14355) --- 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; } }