[debugger] EA-1376775 Fix dispose SuspendContextImpl

GitOrigin-RevId: 35d4183b8a8fd37035a90dd829b1565c618d561f
This commit is contained in:
Maksim Zuev
2024-10-02 16:46:24 +00:00
committed by intellij-monorepo-bot
parent 5282faf9c3
commit 52bdda1380
@@ -16,6 +16,7 @@ import com.intellij.debugger.jdi.VirtualMachineProxyImpl;
import com.intellij.debugger.settings.DebuggerSettings;
import com.intellij.openapi.Disposable;
import com.intellij.openapi.diagnostic.Logger;
import com.intellij.openapi.util.CheckedDisposable;
import com.intellij.openapi.util.Disposer;
import com.intellij.xdebugger.frame.XExecutionStack;
import com.intellij.xdebugger.frame.XSuspendContext;
@@ -95,7 +96,14 @@ public abstract class SuspendContextImpl extends XSuspendContext implements Susp
myVotesToVote = eventVotes;
myEventSet = set;
myDebugId = debugId;
Disposer.register(debugProcess.disposable, this);
CheckedDisposable disposable = debugProcess.disposable;
if (disposable.isDisposed()) {
// could be due to VM death
Disposer.dispose(this);
}
else {
Disposer.register(disposable, this);
}
}
public VirtualMachineProxyImpl getVirtualMachineProxy() {
@@ -131,7 +139,7 @@ public abstract class SuspendContextImpl extends XSuspendContext implements Susp
}
private void setThread(@Nullable ThreadReferenceProxyImpl threadProxy) {
if (threadProxy != null && myThread != threadProxy) { // do not add more than once
if (threadProxy != null && myThread != threadProxy && !myDebugProcess.disposable.isDisposed()) { // do not add more than once
threadProxy.addListener(myListener, this);
}
myThread = threadProxy;