提交 f4327351 编写于 作者: A anashaty

8078606: Deadlock in awt clipboard

Reviewed-by: azvegint, bae
上级 d843740b
...@@ -156,19 +156,29 @@ public final class XClipboard extends SunClipboard implements OwnershipListener ...@@ -156,19 +156,29 @@ public final class XClipboard extends SunClipboard implements OwnershipListener
isSelectionNotifyProcessed = true; isSelectionNotifyProcessed = true;
boolean mustSchedule = false; boolean mustSchedule = false;
synchronized (XClipboard.classLock) { XToolkit.awtLock();
if (targetsAtom2Clipboard == null) { try {
targetsAtom2Clipboard = new HashMap<Long, XClipboard>(2); synchronized (XClipboard.classLock) {
try {
Thread.sleep(70);
} catch (InterruptedException e) {
e.printStackTrace(); //To change body of catch statement use File | Settings | File Templates.
}
if (targetsAtom2Clipboard == null) {
targetsAtom2Clipboard = new HashMap<Long, XClipboard>(2);
}
mustSchedule = targetsAtom2Clipboard.isEmpty();
targetsAtom2Clipboard.put(getTargetsPropertyAtom().getAtom(), this);
if (mustSchedule) {
XToolkit.addEventDispatcher(XWindow.getXAWTRootWindow().getWindow(),
new SelectionNotifyHandler());
}
} }
mustSchedule = targetsAtom2Clipboard.isEmpty();
targetsAtom2Clipboard.put(getTargetsPropertyAtom().getAtom(), this);
if (mustSchedule) { if (mustSchedule) {
XToolkit.addEventDispatcher(XWindow.getXAWTRootWindow().getWindow(), XToolkit.schedule(new CheckChangeTimerTask(), XClipboard.getPollInterval());
new SelectionNotifyHandler());
} }
} } finally {
if (mustSchedule) { XToolkit.awtUnlock();
XToolkit.schedule(new CheckChangeTimerTask(), XClipboard.getPollInterval());
} }
} }
......
...@@ -31,18 +31,22 @@ package sun.awt.X11; ...@@ -31,18 +31,22 @@ package sun.awt.X11;
* common logical ancestor * common logical ancestor
*/ */
class XRootWindow extends XBaseWindow { class XRootWindow extends XBaseWindow {
private static XRootWindow xawtRootWindow = null; private static class LazyHolder {
static XRootWindow getInstance() { private static final XRootWindow xawtRootWindow;
XToolkit.awtLock();
try { static {
if (xawtRootWindow == null) { XToolkit.awtLock();
try {
xawtRootWindow = new XRootWindow(); xawtRootWindow = new XRootWindow();
xawtRootWindow.init(xawtRootWindow.getDelayedParams().delete(DELAYED)); xawtRootWindow.init(xawtRootWindow.getDelayedParams().delete(DELAYED));
} finally {
XToolkit.awtUnlock();
} }
return xawtRootWindow;
} finally {
XToolkit.awtUnlock();
} }
}
static XRootWindow getInstance() {
return LazyHolder.xawtRootWindow;
} }
private XRootWindow() { private XRootWindow() {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册