From 88ed454169605cff8e402a8221e13ac0593b6f61 Mon Sep 17 00:00:00 2001 From: cTn Date: Mon, 10 Feb 2014 16:26:43 +0100 Subject: [PATCH] bugfix / cleanup routine for delayed data requests that could leak into CLI and cause corruption --- js/msp.js | 13 ++++++++----- tabs/cli.js | 3 +++ 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/js/msp.js b/js/msp.js index 1d7b2c85..a560fabb 100644 --- a/js/msp.js +++ b/js/msp.js @@ -67,17 +67,20 @@ var MSP = { callbacks: [], packet_error: 0, - disconnect_cleanup: function() { - this.state = 0; // reset packet state for "clean" initial entry (this is only required if user hot-disconnects) - this.packet_error = 0; // reset CRC packet error counter for next session - - // kill all "raw" MSP timers + callbacks_cleanup: function() { for (var i = 0; i < this.callbacks.length; i++) { clearInterval(this.callbacks[i].timer); } // drop references this.callbacks = []; + }, + + disconnect_cleanup: function() { + this.state = 0; // reset packet state for "clean" initial entry (this is only required if user hot-disconnects) + this.packet_error = 0; // reset CRC packet error counter for next session + + this.callbacks_cleanup(); } }; diff --git a/tabs/cli.js b/tabs/cli.js index 953a28f4..a47d30f3 100644 --- a/tabs/cli.js +++ b/tabs/cli.js @@ -27,6 +27,9 @@ function tab_initialize_cli() { $('#content').load("./tabs/cli.html", function() { GUI.active_tab = 'cli'; + // remove any active interval for delayed command + MSP.callbacks_cleanup(); + CLI_active = true; // Enter CLI mode