Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 18 additions & 17 deletions platform/core.startup/src/org/netbeans/core/startup/Splash.java
Original file line number Diff line number Diff line change
Expand Up @@ -300,6 +300,8 @@ private static class Progress {
private volatile int barLength = 0;
private volatile String text;

private long next;

private void increment(SplashPainter painter, int steps) {
if (steps <= 0) {
return;
Expand All @@ -311,12 +313,15 @@ private void increment(SplashPainter painter, int steps) {
int bl = painter.bar.width * progress / maxSteps - barStart;
if (bl > 1 || barStart % 2 == 0) {
barLength = bl;
onEDT(() -> {
/* Don't try to be smart about which section of the bar to repaint.
There can be tricky rounding issues on HiDPI screens with non-integral
scaling factors (e.g. 150%). */
painter.repaint(painter.bar);
});
if (next < System.currentTimeMillis()) {
onEDT(() -> {
/* Don't try to be smart about which section of the bar to repaint.
There can be tricky rounding issues on HiDPI screens with non-integral
scaling factors (e.g. 150%). */
painter.repaint(painter.bar);
});
next = System.currentTimeMillis() + 50;
}
}
}
}
Expand Down Expand Up @@ -546,21 +551,17 @@ public SplashPainter(Progress model, Graphics graphics, JComponent comp, boolean
}
}

long next;
final void repaint(Rectangle r) {
if (comp != null) {
comp.repaint(r);
} else {
if (next < System.currentTimeMillis()) {
paint();
try {
SplashScreen ss = SplashScreen.getSplashScreen();
if (ss != null) {
ss.update();
}
} catch (IllegalStateException splashAlreadyClosed) {}
next = System.currentTimeMillis() + 200;
}
paint();

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IIRC we don't reach this code in practice any more - comp is never null?

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the original logic (which was left in tact when splash was moved to the EDT in #9303) is still in place.

setRunning() checks if getSplashScreen() returns something, if it does it initializes a different painter while leaving comp null. So this branch is still theoretically reachable when the splash launcher flag is used. It still exists in the windows launcher AFAIR. I remember testing this with two splash pngs, one was green one was blue - probably a comment somewhere on the original PR.

Also: i think setRunning(false) should also set comp to null but I probably didn't do that since the getter is public - this could cause an NPE somewhere.

@neilcsmith-net neilcsmith-net Oct 8, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure, if you manually create the splash file it might trigger, but the code to actually generate that file doesn't run since #1246 So, in practice this timing code using next is not used in the current release.

That wasn't an argument against your approach, or in favour of removing the comp == null code. Just a useful note to consider in reviewing what has actually changed here during startup.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I just didn't want to merge before answering the question ;)

try {
SplashScreen ss = SplashScreen.getSplashScreen();
if (ss != null) {
ss.update();
}
} catch (IllegalStateException splashAlreadyClosed) {}
}
}

Expand Down
Loading