From eb11d7926ce72c4c68ef87334b53b42cc9139f74 Mon Sep 17 00:00:00 2001 From: Sam El-Husseini Date: Tue, 2 Jan 2018 23:18:54 -0800 Subject: [PATCH] Fix null dereferencing issue for buttons --- libs/core/buttons.ts | 1 + libs/core/input.ts | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/libs/core/buttons.ts b/libs/core/buttons.ts index 993d319f..e29af19c 100644 --- a/libs/core/buttons.ts +++ b/libs/core/buttons.ts @@ -66,6 +66,7 @@ namespace brick { //% hidden _update(curr: boolean) { + if (curr === null) return if (this._isPressed == curr) return this._isPressed = curr if (curr) { diff --git a/libs/core/input.ts b/libs/core/input.ts index 440dfbe8..e67bc1a2 100644 --- a/libs/core/input.ts +++ b/libs/core/input.ts @@ -68,7 +68,7 @@ namespace sensors.internal { if (info.sensor) return info.sensor._query() return 0 }, (prev, curr) => { - if (info.sensor && curr !== null) info.sensor._update(prev, curr) + if (info.sensor && curr != null) info.sensor._update(prev, curr) }) }