Skip to content

fix debugger initialization #86

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Jan 4, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 33 additions & 12 deletions lib/debugger/debugger.dart
Original file line number Diff line number Diff line change
Expand Up @@ -33,26 +33,22 @@ import '../ui/primer.dart';

class DebuggerScreen extends Screen {
DebuggerScreen()
: super(name: 'Debugger', id: 'debugger', iconClass: 'octicon-bug') {
: debuggerState = new DebuggerState(),
super(name: 'Debugger', id: 'debugger', iconClass: 'octicon-bug') {
deviceStatus = new StatusItem();
addStatusItem(deviceStatus);

serviceManager.onConnectionAvailable.listen(_handleConnectionStart);
if (serviceManager.hasConnection) {
_handleConnectionStart(serviceManager.service);
}
serviceManager.isolateManager.onSelectedIsolateChanged
.listen(_handleIsolateChanged);
serviceManager.onConnectionClosed.listen(_handleConnectionStop);
}

final DebuggerState debuggerState;

bool _initialized = false;

StatusItem deviceStatus;

CoreElement _breakpointsCountDiv;
CoreElement _sourcePathDiv;

SourceEditor sourceEditor;
DebuggerState debuggerState;
CallStackView callStackView;
VariablesView variablesView;
BreakpointsView breakpointsView;
Expand All @@ -63,8 +59,6 @@ class DebuggerScreen extends Screen {
void createContent(Framework framework, CoreElement mainDiv) {
CoreElement sourceArea;

debuggerState = new DebuggerState();

final PButton resumeButton = new PButton(null)
..primary()
..small()
Expand Down Expand Up @@ -243,6 +237,25 @@ class DebuggerScreen extends Screen {
consoleArea.refresh();
}

@override
void entering() {
if (!_initialized) {
_initialize();
}
}

void _initialize() {
_initialized = true;

serviceManager.onConnectionAvailable.listen(_handleConnectionStart);
if (serviceManager.hasConnection) {
_handleConnectionStart(serviceManager.service);
}
serviceManager.isolateManager.onSelectedIsolateChanged
.listen(_handleIsolateChanged);
serviceManager.onConnectionClosed.listen(_handleConnectionStop);
}

CoreElement _buildMenuNav() {
callStackView = new CallStackView();

Expand Down Expand Up @@ -362,6 +375,10 @@ class DebuggerScreen extends Screen {
final String message = decodeBase64(e.bytes);
consoleArea.append(message, isError: true);
});

if (serviceManager.isolateManager.selectedIsolate != null) {
_handleIsolateChanged(serviceManager.isolateManager.selectedIsolate);
}
}

void _handleIsolateChanged(IsolateRef isolateRef) {
Expand All @@ -373,6 +390,10 @@ class DebuggerScreen extends Screen {
return;
}

if (isolateRef == debuggerState.isolateRef) {
return;
}

debuggerState.switchToIsolate(isolateRef);

serviceManager.service.getIsolate(isolateRef.id).then((dynamic result) {
Expand Down