Skip to content

Commit 8f8194e

Browse files
committed
Fail Laf installation if laf is currently being installed.
1 parent a9ae43f commit 8f8194e

File tree

1 file changed

+7
-0
lines changed

1 file changed

+7
-0
lines changed

core/src/main/java/com/github/weisj/darklaf/LafInstaller.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
package com.github.weisj.darklaf;
2323

2424
import java.awt.Window;
25+
import java.util.concurrent.atomic.AtomicBoolean;
2526
import java.util.logging.Level;
2627
import java.util.logging.Logger;
2728

@@ -38,10 +39,14 @@
3839
final 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

0 commit comments

Comments
 (0)