From 8e8e9a5a580a1153d550356421dcf24c4d73bc3c Mon Sep 17 00:00:00 2001 From: Michael du Breuil Date: Tue, 26 Jun 2018 10:47:00 -0700 Subject: [PATCH] AP_Notify: Delete drivers that are not present --- libraries/AP_Notify/AP_Notify.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/libraries/AP_Notify/AP_Notify.cpp b/libraries/AP_Notify/AP_Notify.cpp index 97b5ccb029..641592cb68 100644 --- a/libraries/AP_Notify/AP_Notify.cpp +++ b/libraries/AP_Notify/AP_Notify.cpp @@ -259,19 +259,22 @@ void AP_Notify::add_backends(void) // initialisation void AP_Notify::init(bool enable_external_leds) { - // add all the backends - add_backends(); - // clear all flags and events memset(&AP_Notify::flags, 0, sizeof(AP_Notify::flags)); memset(&AP_Notify::events, 0, sizeof(AP_Notify::events)); AP_Notify::flags.external_leds = enable_external_leds; + // add all the backends + add_backends(); + for (uint8_t i = 0; i < _num_devices; i++) { if (_devices[i] != nullptr) { _devices[i]->pNotify = this; - _devices[i]->init(); + if(!_devices[i]->init()) { + delete _devices[i]; + _devices[i] = nullptr; + } } } }