changeset 1795:97c119db6c89

8192030: Better MTSchema support Reviewed-by: skoivu, rhalade, prr, aghaisas
author serb
date Sun, 10 Dec 2017 19:01:40 -0800
parents 48c243b4ef12
children 5bfbe17c45bc
files src/windows/classes/sun/awt/windows/ThemeReader.java src/windows/native/sun/windows/ThemeReader.cpp
diffstat 2 files changed, 18 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/src/windows/classes/sun/awt/windows/ThemeReader.java	Wed Feb 07 00:09:23 2018 -0800
+++ b/src/windows/classes/sun/awt/windows/ThemeReader.java	Sun Dec 10 19:01:40 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2004, 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
@@ -57,6 +57,7 @@
     private static final Lock readLock = readWriteLock.readLock();
     private static final Lock writeLock = readWriteLock.writeLock();
     private static volatile boolean valid = false;
+    private static volatile boolean isThemed;
 
     static void flush() {
         // Could be called on Toolkit thread, so do not try to aquire locks
@@ -64,7 +65,17 @@
         valid = false;
     }
 
-    public native static boolean isThemed();
+    private static native boolean initThemes();
+
+    public static boolean isThemed() {
+        writeLock.lock();
+        try {
+            isThemed = initThemes();
+            return isThemed;
+        } finally {
+            writeLock.unlock();
+        }
+    }
 
     // this should be called only with writeLock held
     private static Long getThemeImpl(String widget) {
@@ -88,6 +99,9 @@
     // returns theme value
     // this method should be invoked with readLock locked
     private static Long getTheme(String widget) {
+        if (!isThemed) {
+            throw new IllegalStateException("Themes are not loaded");
+        }
         if (!valid) {
             readLock.unlock();
             writeLock.lock();
--- a/src/windows/native/sun/windows/ThemeReader.cpp	Wed Feb 07 00:09:23 2018 -0800
+++ b/src/windows/native/sun/windows/ThemeReader.cpp	Sun Dec 10 19:01:40 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2003, 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
@@ -225,7 +225,7 @@
     return FALSE;
 }
 
-JNIEXPORT jboolean JNICALL Java_sun_awt_windows_ThemeReader_isThemed
+JNIEXPORT jboolean JNICALL Java_sun_awt_windows_ThemeReader_initThemes
 (JNIEnv *env, jclass klass) {
     static BOOL TryLoadingThemeLib = FALSE;
     static BOOL Themed = FALSE;