mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-23 04:57:58 +01:00
Fixed delay/thread locking when setting the file drop target
This commit is contained in:
parent
047fb49ac1
commit
bba9a36996
1 changed files with 11 additions and 3 deletions
|
@ -74,7 +74,7 @@ public class GLWindow extends DropTarget {
|
||||||
private JFrame frame;
|
private JFrame frame;
|
||||||
private Canvas canvas;
|
private Canvas canvas;
|
||||||
|
|
||||||
private DropTargetListener dropListener = null;
|
private volatile DropTargetListener dropListener = null;
|
||||||
|
|
||||||
private int windowState = 0;
|
private int windowState = 0;
|
||||||
|
|
||||||
|
@ -241,21 +241,29 @@ public class GLWindow extends DropTarget {
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void clearDropTargetListener() {
|
public synchronized void clearDropTargetListener() {
|
||||||
|
SwingUtilities.invokeLater(this::syncClearDropTargetListener);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void syncClearDropTargetListener() {
|
||||||
if (dropListener != null) {
|
if (dropListener != null) {
|
||||||
if (!ready) {
|
if (!ready) {
|
||||||
FileDropper.getAWTContext().hide(dropListener);
|
FileDropper.getAWTContext().hide(dropListener);
|
||||||
return;
|
|
||||||
} else {
|
} else {
|
||||||
frame.setDropTarget(null);
|
frame.setDropTarget(null);
|
||||||
removeDropTargetListener(dropListener);
|
removeDropTargetListener(dropListener);
|
||||||
}
|
}
|
||||||
|
|
||||||
dropListener = null;
|
dropListener = null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized void setDropTargetListener(FileDropListener dtl) {
|
public synchronized void setDropTargetListener(FileDropListener dtl) {
|
||||||
|
SwingUtilities.invokeLater(() -> syncSetDropTargetListener(dtl));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void syncSetDropTargetListener(FileDropListener dtl) {
|
||||||
try {
|
try {
|
||||||
clearDropTargetListener();
|
syncClearDropTargetListener();
|
||||||
|
|
||||||
dropListener = dtl;
|
dropListener = dtl;
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue