From a8196c9f8423eef38b595e38e6affa6ec3121145 Mon Sep 17 00:00:00 2001 From: Tom Early Date: Wed, 1 Dec 2021 17:12:06 -0700 Subject: [PATCH] housekeeping --- Controller.cpp | 18 ++++++++++++++++-- Main.cpp | 3 +++ 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/Controller.cpp b/Controller.cpp index 35b0213..2c2ca29 100644 --- a/Controller.cpp +++ b/Controller.cpp @@ -35,9 +35,23 @@ bool CController::Start() void CController::Stop() { keep_running = false; - reflectorThread.get(); - ambeThread.get(); + if (reflectorThread.valid()) + reflectorThread.get(); + if (ambeThread.valid()) + ambeThread.get(); reader.Close(); + for (auto &it : dstar_device) + { + it->CloseDevice(); + it.reset(); + } + dstar_device.clear(); + for (auto &it : dmr_device) + { + it->CloseDevice(); + it.reset(); + } + dmr_device.clear(); } bool CController::InitDevices() diff --git a/Main.cpp b/Main.cpp index 120b1e1..3814d59 100644 --- a/Main.cpp +++ b/Main.cpp @@ -14,6 +14,7 @@ // You should have received a copy of the GNU General Public License // along with this program. If not, see . +#include #include #include "Controller.h" @@ -24,6 +25,8 @@ int main() if (controller.Start()) return EXIT_FAILURE; + pause(); + controller.Stop(); return EXIT_SUCCESS;