[Bug/Unregister] Fix the bug related to unregisterModels()
authorDongju Chae <dongju.chae@samsung.com>
Wed, 23 Sep 2020 06:13:47 +0000 (15:13 +0900)
committer채동주/On-Device Lab(SR)/Staff Engineer/삼성전자 <dongju.chae@samsung.com>
Wed, 23 Sep 2020 09:32:36 +0000 (18:32 +0900)
This patch fixes the bug related to unregisterModels ().
The original codes just clear a model vector structure,
which was supposed to call unsetModel() per each model.

Signed-off-by: Dongju Chae <dongju.chae@samsung.com>
src/core/ne-handler.cc

index cf16965..080ccd0 100644 (file)
@@ -529,7 +529,18 @@ HostHandler::unregisterModel (uint32_t modelid)
 int
 HostHandler::unregisterModels ()
 {
-  models_.clear ();
+  std::function <bool (Model *)> functor =
+    [&] (Model *m) -> bool {
+      bool can_remove = true;
+      int status = device_->unsetModel (m);
+      if (status != 0) {
+        logwarn (TAG, "Failed to unset model: %d\n", status);
+        can_remove = false;
+      }
+      return can_remove;
+    };
+
+  models_.for_each (functor);
   return 0;
 }