提交 64cda408 编写于 作者: P pchelko

8042590: Running form URL throws NPE

Reviewed-by: anthony, serb
上级 e6fad1b8
...@@ -56,18 +56,12 @@ public class ThemeReader { ...@@ -56,18 +56,12 @@ public class ThemeReader {
new ReentrantReadWriteLock(); new ReentrantReadWriteLock();
private static final Lock readLock = readWriteLock.readLock(); private static final Lock readLock = readWriteLock.readLock();
private static final Lock writeLock = readWriteLock.writeLock(); private static final Lock writeLock = readWriteLock.writeLock();
private static volatile boolean valid = false;
static void flush() { static void flush() {
writeLock.lock(); // Could be called on Toolkit thread, so do not try to aquire locks
try { // to avoid deadlock with theme initialization
// Close old themes. valid = false;
for (Long value : widgetToTheme.values()) {
closeTheme(value.longValue());
}
widgetToTheme.clear();
} finally {
writeLock.unlock();
}
} }
public native static boolean isThemed(); public native static boolean isThemed();
...@@ -94,6 +88,24 @@ public class ThemeReader { ...@@ -94,6 +88,24 @@ public class ThemeReader {
// returns theme value // returns theme value
// this method should be invoked with readLock locked // this method should be invoked with readLock locked
private static Long getTheme(String widget) { private static Long getTheme(String widget) {
if (!valid) {
readLock.unlock();
writeLock.lock();
try {
if (!valid) {
// Close old themes.
for (Long value : widgetToTheme.values()) {
closeTheme(value);
}
widgetToTheme.clear();
valid = true;
}
} finally {
readLock.lock();
writeLock.unlock();
}
}
// mostly copied from the javadoc for ReentrantReadWriteLock // mostly copied from the javadoc for ReentrantReadWriteLock
Long theme = widgetToTheme.get(widget); Long theme = widgetToTheme.get(widget);
if (theme == null) { if (theme == null) {
......
...@@ -867,7 +867,16 @@ public class WToolkit extends SunToolkit implements Runnable { ...@@ -867,7 +867,16 @@ public class WToolkit extends SunToolkit implements Runnable {
* Windows doesn't always send WM_SETTINGCHANGE when it should. * Windows doesn't always send WM_SETTINGCHANGE when it should.
*/ */
private void windowsSettingChange() { private void windowsSettingChange() {
EventQueue.invokeLater(this::updateProperties); if (AppContext.getAppContext() == null) {
// We cannot post the update to any EventQueue. Listeners will
// be called on EDTs by DesktopPropertyChangeSupport
updateProperties();
} else {
// Cannot update on Toolkit thread.
// DesktopPropertyChangeSupport will call listeners on Toolkit
// thread if it has AppContext (standalone mode)
EventQueue.invokeLater(this::updateProperties);
}
} }
private synchronized void updateProperties() { private synchronized void updateProperties() {
......
...@@ -436,6 +436,7 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer, ...@@ -436,6 +436,7 @@ public class WWindowPeer extends WPanelPeer implements WindowPeer,
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static long[] getActiveWindowHandles() { public static long[] getActiveWindowHandles() {
AppContext appContext = AppContext.getAppContext(); AppContext appContext = AppContext.getAppContext();
if (appContext == null) return null;
synchronized (appContext) { synchronized (appContext) {
List<WWindowPeer> l = (List<WWindowPeer>)appContext.get(ACTIVE_WINDOWS_KEY); List<WWindowPeer> l = (List<WWindowPeer>)appContext.get(ACTIVE_WINDOWS_KEY);
if (l == null) { if (l == null) {
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册