mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-18 09:34:34 +07:00
clean debugger even queue on close
This commit is contained in:
@@ -66,10 +66,7 @@ import com.intellij.openapi.editor.Document;
|
||||
import com.intellij.openapi.extensions.Extensions;
|
||||
import com.intellij.openapi.project.Project;
|
||||
import com.intellij.openapi.ui.Messages;
|
||||
import com.intellij.openapi.util.Comparing;
|
||||
import com.intellij.openapi.util.Key;
|
||||
import com.intellij.openapi.util.Pair;
|
||||
import com.intellij.openapi.util.Ref;
|
||||
import com.intellij.openapi.util.*;
|
||||
import com.intellij.openapi.wm.ToolWindowId;
|
||||
import com.intellij.openapi.wm.WindowManager;
|
||||
import com.intellij.psi.PsiDocumentManager;
|
||||
@@ -585,15 +582,17 @@ public abstract class DebugProcessImpl implements DebugProcess {
|
||||
}
|
||||
|
||||
public void showStatusText(final String text) {
|
||||
myStatusUpdateAlarm.cancelAllRequests();
|
||||
myStatusUpdateAlarm.addRequest(new Runnable() {
|
||||
public void run() {
|
||||
final WindowManager wm = WindowManager.getInstance();
|
||||
if (wm != null) {
|
||||
wm.getStatusBar(myProject).setInfo(text);
|
||||
if (!myStatusUpdateAlarm.isDisposed()) {
|
||||
myStatusUpdateAlarm.cancelAllRequests();
|
||||
myStatusUpdateAlarm.addRequest(new Runnable() {
|
||||
public void run() {
|
||||
final WindowManager wm = WindowManager.getInstance();
|
||||
if (wm != null) {
|
||||
wm.getStatusBar(myProject).setInfo(text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}, 50);
|
||||
}, 50);
|
||||
}
|
||||
}
|
||||
|
||||
static Connector findConnector(String connectorName) throws ExecutionException {
|
||||
@@ -848,7 +847,7 @@ public abstract class DebugProcessImpl implements DebugProcess {
|
||||
|
||||
public void dispose() {
|
||||
NodeRendererSettings.getInstance().removeListener(mySettingsListener);
|
||||
myStatusUpdateAlarm.dispose();
|
||||
Disposer.dispose(myStatusUpdateAlarm);
|
||||
}
|
||||
|
||||
public DebuggerManagerThreadImpl getManagerThread() {
|
||||
|
||||
@@ -224,10 +224,4 @@ public class DebuggerManagerThreadImpl extends InvokeAndWaitThread<DebuggerComma
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public void clearQueue() {
|
||||
myEvents.clearQueue();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -313,11 +313,9 @@ public class DebuggerSession implements AbstractDebuggerSession {
|
||||
|
||||
public void dispose() {
|
||||
ApplicationManager.getApplication().assertIsDispatchThread();
|
||||
DebuggerManagerThreadImpl managerThread = getProcess().getManagerThread();
|
||||
getProcess().dispose();
|
||||
getContextManager().setState(SESSION_EMPTY_CONTEXT, STATE_DISPOSED, EVENT_DISPOSE, null);
|
||||
Disposer.dispose(myUpdateAlarm);
|
||||
managerThread.clearQueue();
|
||||
}
|
||||
|
||||
// ManagerCommands
|
||||
|
||||
@@ -17,9 +17,10 @@ package com.intellij.debugger.impl;
|
||||
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.TestOnly;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.locks.Condition;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
|
||||
@@ -118,7 +119,13 @@ public class EventQueue<E> {
|
||||
}
|
||||
|
||||
public E get() throws EventQueueClosedException {
|
||||
return myCurrentEvent = getEvent();
|
||||
try {
|
||||
return myCurrentEvent = getEvent();
|
||||
}
|
||||
catch (EventQueueClosedException e) {
|
||||
myCurrentEvent = null; // cleanup
|
||||
throw e;
|
||||
}
|
||||
}
|
||||
|
||||
public boolean isClosed() {
|
||||
@@ -129,11 +136,14 @@ public class EventQueue<E> {
|
||||
return myCurrentEvent;
|
||||
}
|
||||
|
||||
@TestOnly
|
||||
public void clearQueue() {
|
||||
myCurrentEvent = null;
|
||||
for (LinkedList event : myEvents) {
|
||||
event.clear();
|
||||
public List<E> clearQueue() {
|
||||
final List<E> allEvents = new ArrayList<E>();
|
||||
for (int i = 0; i < myEvents.length; i++) {
|
||||
final LinkedList<E> eventList = getEventsList(i);
|
||||
while (!eventList.isEmpty()) {
|
||||
allEvents.add(eventList.poll());
|
||||
}
|
||||
}
|
||||
return allEvents;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,6 +19,7 @@ import com.intellij.openapi.application.ApplicationManager;
|
||||
import com.intellij.openapi.diagnostic.Logger;
|
||||
import com.sun.jdi.VMDisconnectedException;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.*;
|
||||
|
||||
/**
|
||||
@@ -142,6 +143,14 @@ public abstract class InvokeThread<E extends PrioritizedTask> {
|
||||
break;
|
||||
}
|
||||
catch (EventQueueClosedException e) {
|
||||
final List<E> unprocessed = myEvents.clearQueue();
|
||||
for (E event : unprocessed) {
|
||||
try {
|
||||
processEvent(event);
|
||||
}
|
||||
catch (Throwable ignored) {
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
catch (RuntimeException e) {
|
||||
|
||||
Reference in New Issue
Block a user