mirror of
https://github.com/JetBrains/JetBrainsRuntime.git
synced 2025-12-06 09:29:38 +01:00
JBR-3813 Regression after fix for JBR-3688
1. Cached bounds and insets must be cloned before return because they
aren't immutable objects.
2. Fixed the deadlock in resetBoundsCache() by synchronizing on a dedicated
lock.
(cherry picked from commit cd5314db8b)
This commit is contained in:
@@ -1190,7 +1190,7 @@ public final class XToolkit extends UNIXToolkit implements Runnable {
|
||||
@Override
|
||||
public Insets getScreenInsets(final GraphicsConfiguration gc) {
|
||||
if (useCachedInsets) {
|
||||
return cachedInsets.computeIfAbsent(gc, this::getScreenInsetsImpl);
|
||||
return (Insets)cachedInsets.computeIfAbsent(gc, this::getScreenInsetsImpl).clone();
|
||||
} else {
|
||||
return getScreenInsetsImpl(gc);
|
||||
}
|
||||
|
||||
@@ -149,21 +149,26 @@ public final class X11GraphicsDevice extends GraphicsDevice
|
||||
}
|
||||
|
||||
private Rectangle boundsCached;
|
||||
private final Object boundsCacheLock = new Object();
|
||||
|
||||
private synchronized Rectangle getBoundsCached() {
|
||||
if (boundsCached == null) {
|
||||
boundsCached = getBoundsImpl();
|
||||
private Rectangle getBoundsCached() {
|
||||
synchronized (boundsCacheLock) {
|
||||
if (boundsCached == null) {
|
||||
boundsCached = getBoundsImpl();
|
||||
}
|
||||
return boundsCached;
|
||||
}
|
||||
return boundsCached;
|
||||
}
|
||||
|
||||
public synchronized void resetBoundsCache() {
|
||||
boundsCached = null;
|
||||
public void resetBoundsCache() {
|
||||
synchronized (boundsCacheLock) {
|
||||
boundsCached = null;
|
||||
}
|
||||
}
|
||||
|
||||
public Rectangle getBounds() {
|
||||
if (X11GraphicsEnvironment.useBoundsCache()) {
|
||||
return getBoundsCached();
|
||||
return new Rectangle(getBoundsCached());
|
||||
}
|
||||
else {
|
||||
return getBoundsImpl();
|
||||
|
||||
Reference in New Issue
Block a user