From 6019207bd431ca879b96d4a18d43ec39fcd8bc71 Mon Sep 17 00:00:00 2001 From: vsonnier Date: Sun, 15 Oct 2017 08:51:01 +0200 Subject: [PATCH] VisualProcessor : protect against null input queue --- src/process/VisualProcessor.h | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/src/process/VisualProcessor.h b/src/process/VisualProcessor.h index e5afd6e..bdc5c2e 100644 --- a/src/process/VisualProcessor.h +++ b/src/process/VisualProcessor.h @@ -29,8 +29,12 @@ public: bool isInputEmpty() { std::lock_guard < std::mutex > busy_lock(busy_update); + + if (input) { + return input->empty(); + } - return input->empty(); + return true; } bool isOutputEmpty() { @@ -84,7 +88,12 @@ public: //this is purposefully (almost) non-blocking call. void flushQueues() { - input->flush(); + //capture a local copy atomically, so we don't need to protect input. + VisualInputQueueTypePtr localInput = input; + + if (localInput) { + localInput->flush(); + } //scoped-lock: create a local copy of outputs, and work with it. std::vector local_outputs;