File tree Expand file tree Collapse file tree 1 file changed +7
-0
lines changed
core/src/main/java/com/github/weisj/darklaf Expand file tree Collapse file tree 1 file changed +7
-0
lines changed Original file line number Diff line number Diff line change 2222package com .github .weisj .darklaf ;
2323
2424import java .awt .Window ;
25+ import java .util .concurrent .atomic .AtomicBoolean ;
2526import java .util .logging .Level ;
2627import java .util .logging .Logger ;
2728
3839final class LafInstaller {
3940
4041 private static final Logger LOGGER = LogUtil .getLogger (LafManager .class );
42+ private static final AtomicBoolean isInstalling = new AtomicBoolean (false );
4143 private static final ThemeEventSupport <ThemeChangeEvent , ThemeChangeListener > eventSupport =
4244 new ThemeEventSupport <>();
4345
4446 void install (final Theme theme ) {
47+ if (!isInstalling .compareAndSet (false , true )) {
48+ throw new IllegalStateException ("Can't install Laf while installation is in progress" );
49+ }
4550 try {
4651 LOGGER .fine (() -> "Installing theme " + theme );
4752 LafTransition transition = LafTransition .showSnapshot ();
@@ -51,6 +56,8 @@ void install(final Theme theme) {
5156 notifyThemeInstalled (theme );
5257 } catch (final UnsupportedLookAndFeelException e ) {
5358 LOGGER .log (Level .SEVERE , "Could not install LaF" , e );
59+ } finally {
60+ isInstalling .set (false );
5461 }
5562 }
5663
You can’t perform that action at this time.
0 commit comments