Skip to content

Commit

Permalink
pyocd: fix continued exception caused by updating TabDebugger after c…
Browse files Browse the repository at this point in the history
…losed.

- Replace active flag with disposed check.
- Added additional checks from from UI jobs.

Signed-off-by: Chris Reed <flit@me.com>
  • Loading branch information
flit committed Dec 30, 2020
1 parent 089a678 commit 452dca7
Showing 1 changed file with 20 additions and 11 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -162,8 +162,6 @@ public class TabDebugger extends AbstractLaunchConfigurationTab {
private String fPyocdPathForOutstandingTargetsLoad;
private RequestMonitor fOutstandingProbesLoadMonitor;
private RequestMonitor fOutstandingTargetsLoadMonitor;

private AtomicBoolean fIsActive = new AtomicBoolean(false);

/**
* Where widgets in a row are rendered in columns, the amount of padding (in
Expand Down Expand Up @@ -1166,9 +1164,9 @@ protected void handleCompleted() {
fOutstandingProbesLoad.setRelease(false);
fOutstandingProbesLoadMonitor = null;

if (!fIsActive.getAcquire()) {
if (getControl().isDisposed()) {
if (Activator.getInstance().isDebugging()) {
System.out.printf("(probes) bailing on updating debugger tab because it's no longer active\n");
System.out.printf("(probes) bailing on updating debugger tab because it has been disposed\n");
}
return;
}
Expand Down Expand Up @@ -1231,6 +1229,14 @@ protected void handleCompleted() {
SystemUIJob updateJob = new SystemUIJob("update probes") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
// Check again to make sure we haven't been disposed.
if (getControl().isDisposed()) {
if (Activator.getInstance().isDebugging()) {
System.out.printf("(probes, from UI job) bailing on updating debugger tab because it has been disposed\n");
}
return Status.OK_STATUS;
}

fGdbServerProbeId.setItems(items);

selectActiveProbe();
Expand Down Expand Up @@ -1286,9 +1292,9 @@ protected void handleCompleted() {
fOutstandingTargetsLoad.setRelease(false);
fOutstandingTargetsLoadMonitor = null;

if (!fIsActive.getAcquire()) {
if (getControl().isDisposed()) {
if (Activator.getInstance().isDebugging()) {
System.out.printf("(targets) bailing on updating debugger tab because it's no longer active\n");
System.out.printf("(targets) bailing on updating debugger tab because it has been disposed\n");
}
return;
}
Expand Down Expand Up @@ -1331,6 +1337,14 @@ protected void handleCompleted() {
SystemUIJob updateJob = new SystemUIJob("update targets") {
@Override
public IStatus runInUIThread(IProgressMonitor monitor) {
// Check again to make sure we haven't been disposed.
if (getControl().isDisposed()) {
if (Activator.getInstance().isDebugging()) {
System.out.printf("(targets, from UI job) bailing on updating debugger tab because it has been disposed\n");
}
return Status.OK_STATUS;
}

fGdbServerTargetName.setItems(itemsToUpdate);

// Select current target from config.
Expand Down Expand Up @@ -1358,8 +1372,6 @@ public IStatus runInUIThread(IProgressMonitor monitor) {

@Override
public void initializeFrom(ILaunchConfiguration configuration) {
fIsActive.setRelease(true);

if (Activator.getInstance().isDebugging()) {
System.out.println("pyocd.TabDebugger.initializeFrom() " + configuration.getName());
}
Expand Down Expand Up @@ -1514,8 +1526,6 @@ public void initializeFrom(ILaunchConfiguration configuration) {
}

public void initializeFromDefaults() {
fIsActive.setRelease(true);

if (Activator.getInstance().isDebugging()) {
System.out.println("pyocd.TabDebugger.initializeFromDefaults()");
}
Expand Down Expand Up @@ -1641,7 +1651,6 @@ public void dispose() {
if (Activator.getInstance().isDebugging()) {
System.out.println("pyocd.TabDebugger.dispose()");
}
fIsActive.setRelease(false);
}

@Override
Expand Down

0 comments on commit 452dca7

Please sign in to comment.