From 7895ea0f42192678bc8ddd0b28dcb827eac83bc7 Mon Sep 17 00:00:00 2001 From: Paul Beckingham Date: Sun, 19 Oct 2014 01:32:41 -0400 Subject: [PATCH] Hooks - Added safety measure in case of a hook misfire. - Made debug output consistent. --- src/Hooks.cpp | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/src/Hooks.cpp b/src/Hooks.cpp index 24967d74e..fae18909f 100644 --- a/src/Hooks.cpp +++ b/src/Hooks.cpp @@ -223,7 +223,7 @@ void Hooks::onExit () // void Hooks::onAdd (std::vector & tasks) { - if (! _enabled) + if (! _enabled || tasks.size () < 1) return; context.timer_hooks.start (); @@ -233,9 +233,7 @@ void Hooks::onAdd (std::vector & tasks) { // Convert vector of tasks to a vector of strings. std::vector input; - std::vector ::const_iterator t; - for (t = tasks.begin (); t != tasks.end (); ++t) - input.push_back (t->composeJSON ()); + input.push_back (tasks[0].composeJSON ()); // Call the hook scripts. std::vector ::iterator script; @@ -456,7 +454,7 @@ int Hooks::callHookScript ( if (_debug >= 2) { - context.debug ("Hook input:"); + context.debug ("Hooks: input"); std::vector ::const_iterator i; for (i = input.begin (); i != input.end (); ++i) context.debug (" " + *i); @@ -475,8 +473,8 @@ int Hooks::callHookScript ( if (_debug >= 2) { - context.debug ("Hook output:"); - std::vector ::const_iterator i; + context.debug ("Hooks: output"); + std::vector ::iterator i; for (i = output.begin (); i != output.end (); ++i) if (*i != "") context.debug (" " + *i);