Skip to content

Commit 6ecf9f5

Browse files
committed
Don't initialize song visualizer when not needed
1 parent 79051ee commit 6ecf9f5

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/main/java/net/raphimc/noteblocktool/frames/SongPlayerFrame.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -303,7 +303,9 @@ public void windowClosing(WindowEvent e) {
303303
public void windowClosed(WindowEvent e) {
304304
SongPlayerFrame.this.songPlayer.stop();
305305
SongPlayerFrame.this.updateTimer.stop();
306-
VisualizerWindow.getInstance().hide();
306+
if (VisualizerWindow.hasInstance()) {
307+
VisualizerWindow.getInstance().hide();
308+
}
307309
if (SongPlayerFrame.this.soundSystem != null) SongPlayerFrame.this.soundSystem.close();
308310
}
309311
});

src/main/java/net/raphimc/noteblocktool/frames/visualizer/VisualizerWindow.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ public static VisualizerWindow getInstance() {
4747
return INSTANCE;
4848
}
4949

50+
public static boolean hasInstance() {
51+
return INSTANCE != null;
52+
}
53+
5054
private VisualizerWindow() {
5155
this.renderThread = new Thread(() -> {
5256
GLFWErrorCallback.createPrint(System.err).set();

0 commit comments

Comments
 (0)