mirror of
https://github.com/MineLittlePony/MineLittlePony.git
synced 2024-11-26 14:27:59 +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 Canvas canvas;
|
||||
|
||||
private DropTargetListener dropListener = null;
|
||||
private volatile DropTargetListener dropListener = null;
|
||||
|
||||
private int windowState = 0;
|
||||
|
||||
|
@ -241,21 +241,29 @@ public class GLWindow extends DropTarget {
|
|||
}
|
||||
|
||||
public synchronized void clearDropTargetListener() {
|
||||
SwingUtilities.invokeLater(this::syncClearDropTargetListener);
|
||||
}
|
||||
|
||||
private void syncClearDropTargetListener() {
|
||||
if (dropListener != null) {
|
||||
if (!ready) {
|
||||
FileDropper.getAWTContext().hide(dropListener);
|
||||
return;
|
||||
} else {
|
||||
frame.setDropTarget(null);
|
||||
removeDropTargetListener(dropListener);
|
||||
}
|
||||
|
||||
dropListener = null;
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized void setDropTargetListener(FileDropListener dtl) {
|
||||
SwingUtilities.invokeLater(() -> syncSetDropTargetListener(dtl));
|
||||
}
|
||||
|
||||
private void syncSetDropTargetListener(FileDropListener dtl) {
|
||||
try {
|
||||
clearDropTargetListener();
|
||||
syncClearDropTargetListener();
|
||||
|
||||
dropListener = dtl;
|
||||
|
||||
|
|
Loading…
Reference in a new issue