From 9755006941a3345938c9b6e911f4318bc58d5364 Mon Sep 17 00:00:00 2001 From: Matthew Butler Date: Tue, 13 Oct 2020 13:35:09 -0300 Subject: [PATCH] Resolve bug in Node.removeChild removeChild treated `children` as a List of nodes, rather than a map of String,Node (nodeNames as the String). This meant trying to remove the Node from the list would silently fail every call. --- CHANGELOG.md | 1 + lib/src/common/node.dart | 9 +++++++-- pubspec.yaml | 2 +- 3 files changed, 9 insertions(+), 3 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index cacd6c64..404dd5a0 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,6 @@ # ChangeLog +* v1.0.6 - Fix a logic error in removeChild method of Nodes. * v1.0.5 - Ensure that QOS downgrades are propagated. * v1.0.4+1 - Map logger names to match DSA log levels. * v1.0.4 - Forward any errors generated by a `list` request to the requester. diff --git a/lib/src/common/node.dart b/lib/src/common/node.dart index 4b0d9073..3c285dba 100644 --- a/lib/src/common/node.dart +++ b/lib/src/common/node.dart @@ -73,10 +73,15 @@ class Node { /// [input] can be either an instance of [Node] or a [String]. String removeChild(dynamic input) { if (input is String) { - children.remove(getChild(input)); + children.remove(input); return input; } else if (input is Node) { - children.remove(input); + for (var nodeName in children.keys.toList()) { + if ((input as Node) == children[nodeName]) { + children.remove(nodeName); + return nodeName; + } + } } else { throw new Exception("Invalid Input"); } diff --git a/pubspec.yaml b/pubspec.yaml index 721cb34f..c3018fdd 100644 --- a/pubspec.yaml +++ b/pubspec.yaml @@ -1,5 +1,5 @@ name: dslink -version: 1.0.5 +version: 1.0.6 description: "DSA IoT Platform - DSLink SDK for Dart" homepage: "http://iot-dsa.org" documentation: "https://iot-dsa.github.io/docs/sdks/dart/"