mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-23 14:32:59 -05:00
Fixing debug statements and also adding a safety check for timeoutIDs.
This commit is contained in:
parent
0e250aef37
commit
704774d6d1
6 changed files with 21 additions and 11 deletions
|
@ -840,7 +840,7 @@ class Boost {
|
|||
*/
|
||||
reset () {
|
||||
console.log('BOOST RESET CALLED');
|
||||
|
||||
|
||||
this._ports = [];
|
||||
this._motors = [];
|
||||
this._sensors = {
|
||||
|
|
|
@ -614,7 +614,7 @@ class EV3 {
|
|||
*/
|
||||
reset() {
|
||||
console.log('EV3 RESET CALLED');
|
||||
|
||||
|
||||
this._sensorPorts = [];
|
||||
this._motorPorts = [];
|
||||
this._sensors = {
|
||||
|
@ -624,8 +624,10 @@ class EV3 {
|
|||
};
|
||||
this._motors = [null, null, null, null];
|
||||
|
||||
window.clearInterval(this._pollingIntervalID);
|
||||
this._pollingIntervalID = null;
|
||||
if (this._pollingIntervalID) {
|
||||
window.clearInterval(this._pollingIntervalID);
|
||||
this._pollingIntervalID = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -224,7 +224,7 @@ class GdxFor {
|
|||
*/
|
||||
reset () {
|
||||
console.log('GDXFOR RESET CALLED');
|
||||
|
||||
|
||||
this._sensors = {
|
||||
force: 0,
|
||||
accelerationX: 0,
|
||||
|
@ -235,7 +235,10 @@ class GdxFor {
|
|||
spinSpeedZ: 0
|
||||
};
|
||||
|
||||
window.clearInterval(this._timeoutID);
|
||||
if (this._timeoutID) {
|
||||
window.clearInterval(this._timeoutID);
|
||||
this._timeoutID = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -254,7 +254,10 @@ class MicroBit {
|
|||
reset() {
|
||||
console.log('MICROBIT RESET CALLED');
|
||||
|
||||
window.clearTimeout(this._timeoutID);
|
||||
if (this._timeoutID) {
|
||||
window.clearTimeout(this._timeoutID);
|
||||
this._timeoutID = null;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -203,8 +203,9 @@ class BLE extends JSONRPC {
|
|||
* Disconnect the socket, and if the extension using this socket has a
|
||||
* reset callback, call it. Finally, emit an error to the runtime.
|
||||
*/
|
||||
handleDisconnectError (/* e */) {
|
||||
// log.error(`BLE error: ${JSON.stringify(e)}`);
|
||||
handleDisconnectError (e) {
|
||||
console.error(`BLE error: ${JSON.stringify(e)}`);
|
||||
console.error(e);
|
||||
console.log('BLE HANDLEDISCONNECTERROR CALLED');
|
||||
|
||||
if (!this._connected) return;
|
||||
|
|
|
@ -149,8 +149,9 @@ class BT extends JSONRPC {
|
|||
* Disconnect the socket, and if the extension using this socket has a
|
||||
* reset callback, call it. Finally, emit an error to the runtime.
|
||||
*/
|
||||
handleDisconnectError (/* e */) {
|
||||
// log.error(`BT error: ${JSON.stringify(e)}`);
|
||||
handleDisconnectError (e) {
|
||||
console.error(`BT error: ${JSON.stringify(e)}`);
|
||||
console.error(e);
|
||||
console.log('BT HANDLEDISCONNECTERROR CALLED');
|
||||
|
||||
if (!this._connected) return;
|
||||
|
|
Loading…
Reference in a new issue