aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlexey Ushakov <Alexey.Ushakov@jetbrains.com>2017-03-10 17:47:55 +0300
committerAlexey Ushakov <Alexey.Ushakov@jetbrains.com>2017-03-10 17:47:55 +0300
commit2522d4d5bac27d21f654d86dc11396b665dd6e98 (patch)
treecca787519d5a060c56b6094b3980e41bd5118d8e
parent8500ba524ee2ac592b1ad9d9f09d2a62c92d1d0e (diff)
downloadjdk8u_jdk-2522d4d5bac27d21f654d86dc11396b665dd6e98.tar.gz
8152683: Deadlock when resuming from sleep with different monitor setupjb8u112-b774.1jb8u112-b774
Backport of jdk9 fix Reviewed-by: serb, vadim Contributed-by: Karl von Randow <karl@xk72.com>
-rw-r--r--src/macosx/classes/sun/awt/CGraphicsEnvironment.java13
1 files changed, 8 insertions, 5 deletions
diff --git a/src/macosx/classes/sun/awt/CGraphicsEnvironment.java b/src/macosx/classes/sun/awt/CGraphicsEnvironment.java
index a117d99f42..77783d14bd 100644
--- a/src/macosx/classes/sun/awt/CGraphicsEnvironment.java
+++ b/src/macosx/classes/sun/awt/CGraphicsEnvironment.java
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
@@ -95,6 +95,10 @@ public final class CGraphicsEnvironment extends SunGraphicsEnvironment {
/** Available CoreGraphics displays. */
private final Map<Integer, CGraphicsDevice> devices = new HashMap<>(5);
+ /**
+ * The key in the {@link #devices} for the main display.
+ */
+ private int mainDisplayID;
/** Reference to the display reconfiguration callback context. */
private final long displayReconfigContext;
@@ -152,15 +156,15 @@ public final class CGraphicsEnvironment extends SunGraphicsEnvironment {
final Map<Integer, CGraphicsDevice> old = new HashMap<>(devices);
devices.clear();
- int mainID = getMainDisplayID();
+ mainDisplayID = getMainDisplayID();
// initialization of the graphics device may change
// list of displays on hybrid systems via an activation
// of discrete video.
// So, we initialize the main display first, and then
// retrieve actual list of displays.
- if (!old.containsKey(mainID)) {
- old.put(mainID, new CGraphicsDevice(mainID));
+ if (!old.containsKey(mainDisplayID)) {
+ old.put(mainDisplayID, new CGraphicsDevice(mainDisplayID));
}
for (final int id : getDisplayIDs()) {
@@ -173,7 +177,6 @@ public final class CGraphicsEnvironment extends SunGraphicsEnvironment {
@Override
public synchronized GraphicsDevice getDefaultScreenDevice() throws HeadlessException {
- final int mainDisplayID = getMainDisplayID();
CGraphicsDevice d = devices.get(mainDisplayID);
if (d == null) {
// we do not expect that this may happen, the only response