From 75f8b3a3491c8a0140605383f11099b3449582ca Mon Sep 17 00:00:00 2001 From: Iuri Matias Date: Thu, 4 Oct 2018 16:36:30 -0400 Subject: [PATCH] refactor unload; remove all direct references to the internal debugger from the UI --- src/app/debugger/debugger/debugger.js | 5 +++++ src/app/debugger/debuggerUI.js | 11 +++++------ 2 files changed, 10 insertions(+), 6 deletions(-) diff --git a/src/app/debugger/debugger/debugger.js b/src/app/debugger/debugger/debugger.js index ee7d146394..8741c4be3d 100644 --- a/src/app/debugger/debugger/debugger.js +++ b/src/app/debugger/debugger/debugger.js @@ -139,4 +139,9 @@ Debugger.prototype.debugTx = function (tx, loadingCb) { this.debugger.debug(tx) } +Debugger.prototype.unload = function () { + this.debugger.unLoad() + this.event.trigger('debuggerUnloaded') +} + module.exports = Debugger diff --git a/src/app/debugger/debuggerUI.js b/src/app/debugger/debuggerUI.js index bbd13a4e6b..c9d1137fb8 100644 --- a/src/app/debugger/debuggerUI.js +++ b/src/app/debugger/debuggerUI.js @@ -37,7 +37,6 @@ class DebuggerUI { compiler: this.registry.get('compiler').api }) - this.debugger = this.transactionDebugger.debugger this.isActive = false this.sourceHighlighter = new SourceHighlighter() @@ -69,7 +68,7 @@ class DebuggerUI { // unload if a file has changed (but not if tabs were switched) self.editor.event.register('contentChanged', function () { - self.debugger.unLoad() + self.transactionDebugger.unload() }) } @@ -83,6 +82,8 @@ class DebuggerUI { this.transactionDebugger.event.register('newSourceLocation', function (lineColumnPos, rawLocation) { self.sourceHighlighter.currentSourceLocation(lineColumnPos, rawLocation) }) + + this.transactionDebugger.event.register('debuggerUnloaded', self.unLoad.bind(this)) } startTxBrowser () { @@ -91,14 +92,12 @@ class DebuggerUI { this.txBrowser = txBrowser txBrowser.event.register('requestDebug', function (blockNumber, txNumber, tx) { - self.debugger.unLoad() - self.unLoad() + self.transactionDebugger.unload() self.startDebugging(blockNumber, txNumber, tx) }) txBrowser.event.register('unloadRequested', this, function (blockNumber, txIndex, tx) { - self.debugger.unLoad() - self.unLoad() + self.transactionDebugger.unload() }) }