From 27f8bc5920eebefefa5bcc0827efbe2c77e27348 Mon Sep 17 00:00:00 2001 From: Mattia Codato Date: Wed, 15 Jul 2020 09:14:01 +0200 Subject: [PATCH] Call ExecuteCommandProcessFinishedHandler for notification and event commands --- lib/methods/plugineventtask.cpp | 9 +++++++-- lib/methods/pluginnotificationtask.cpp | 9 +++++++-- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/lib/methods/plugineventtask.cpp b/lib/methods/plugineventtask.cpp index b2bb466b8..9296df0f1 100644 --- a/lib/methods/plugineventtask.cpp +++ b/lib/methods/plugineventtask.cpp @@ -36,9 +36,14 @@ void PluginEventTask::ScriptFunc(const Checkable::Ptr& checkable, int timeout = commandObj->GetTimeout(); + std::function callback; + if (Checkable::ExecuteCommandProcessFinishedHandler) { + callback = Checkable::ExecuteCommandProcessFinishedHandler; + } else { + callback = std::bind(&PluginEventTask::ProcessFinishedHandler, checkable, _1, _2); + } PluginUtility::ExecuteCommand(commandObj, checkable, checkable->GetLastCheckResult(), - resolvers, resolvedMacros, useResolvedMacros, timeout, - std::bind(&PluginEventTask::ProcessFinishedHandler, checkable, _1, _2)); + resolvers, resolvedMacros, useResolvedMacros, timeout, callback); } void PluginEventTask::ProcessFinishedHandler(const Checkable::Ptr& checkable, const Value& commandLine, const ProcessResult& pr) diff --git a/lib/methods/pluginnotificationtask.cpp b/lib/methods/pluginnotificationtask.cpp index 0fcc95dc2..b81708cf3 100644 --- a/lib/methods/pluginnotificationtask.cpp +++ b/lib/methods/pluginnotificationtask.cpp @@ -53,9 +53,14 @@ void PluginNotificationTask::ScriptFunc(const Notification::Ptr& notification, int timeout = commandObj->GetTimeout(); + std::function callback; + if (Checkable::ExecuteCommandProcessFinishedHandler) { + callback = Checkable::ExecuteCommandProcessFinishedHandler; + } else { + callback = std::bind(&PluginNotificationTask::ProcessFinishedHandler, checkable, _1, _2); + } PluginUtility::ExecuteCommand(commandObj, checkable, cr, resolvers, - resolvedMacros, useResolvedMacros, timeout, - std::bind(&PluginNotificationTask::ProcessFinishedHandler, checkable, _1, _2)); + resolvedMacros, useResolvedMacros, timeout, callback); } void PluginNotificationTask::ProcessFinishedHandler(const Checkable::Ptr& checkable, const Value& commandLine, const ProcessResult& pr)