mirror of
https://gitflic.ru/project/openide/openide.git
synced 2026-09-27 10:03:11 +07:00
Invalid elements are now removed from the CopyPasteManager on project closing
This commit is contained in:
@@ -50,15 +50,18 @@ public class PsiCopyPasteManager {
|
||||
ApplicationManager.getApplication().getMessageBus().connect().subscribe(ProjectManager.TOPIC, new ProjectManagerListener() {
|
||||
@Override
|
||||
public void projectClosing(@NotNull Project project) {
|
||||
if (myRecentData != null && myRecentData.getProject() == project) {
|
||||
if (myRecentData != null && (myRecentData.isValid() || myRecentData.getProject() == project)) {
|
||||
myRecentData = null;
|
||||
}
|
||||
|
||||
Transferable[] contents = myCopyPasteManager.getAllContents();
|
||||
for (int i = contents.length - 1; i >= 0; i--) {
|
||||
Transferable t = contents[i];
|
||||
if (t instanceof MyTransferable && ((MyTransferable)t).myDataProxy.getProject() == project) {
|
||||
myCopyPasteManager.removeContent(t);
|
||||
if (t instanceof MyTransferable) {
|
||||
MyData myData = ((MyTransferable)t).myDataProxy;
|
||||
if (!myData.isValid() || myData.getProject() == project) {
|
||||
myCopyPasteManager.removeContent(t);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -183,6 +186,10 @@ public class PsiCopyPasteManager {
|
||||
return myIsCopied;
|
||||
}
|
||||
|
||||
public boolean isValid() {
|
||||
return myElements.length > 0 && myElements[0].isValid();
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Project getProject() {
|
||||
if (myElements == null || myElements.length == 0) {
|
||||
|
||||
Reference in New Issue
Block a user