On Sat, 8 Aug 2026 18:50:33 GMT, Marius Hanl <[email protected]> wrote:
>> modules/javafx.graphics/src/main/java/javafx/stage/PopupWindow.java line 521:
>>
>>> 519: Scene scene = getScene();
>>> 520: if (scene.getUserAgentStylesheet() == null &&
>>> ownerScene.getUserAgentStylesheet() != null) {
>>> 521:
>>> scene.setUserAgentStylesheet(ownerScene.getUserAgentStylesheet());
>>
>> there might be another issue:
>> - owner A has the user agent stylesheet A.css
>> - a popup with no stylesheet is shown with the owner A. A.css is shown
>> - the popup gets hidden
>> - either owner A changes the stylesheet to B.css, or the popup is reusing
>> with a different owner
>> - the popup gets shown
>>
>> since `scene.getUserAgentStylesheet()` is already A.css, this code does not
>> set the new stylesheet, leaving the popup with a wrong style.
>>
>> I know reusing the popup (context menu, etc.) is a bad idea, but
>> surprisingly, I saw this happen many times in the past.
>
> AFAIK, there is no way that you can actually change the user agent
> stylesheet. It is read once and then cached.
> See e.g. https://github.com/openjdk/jfx/pull/525, where a user proposed to
> change that.
>
> So I think we are actually good here
Here is the case for the `PopupTest` that works in master and fails with this
fix:
@Test
public void updateStylesheetFromOwnerStage() {
String cssA = toBase64(".root { -fx-fill: green; }");
String cssB = toBase64(".root { -fx-fill: red; }");
scene.setUserAgentStylesheet(cssA);
Popup p = new Popup();
p.show(stage);
assertEquals(cssA, p.getScene().getUserAgentStylesheet());
p.hide();
scene.setUserAgentStylesheet(cssB);
p.show(stage);
assertEquals(cssB, p.getScene().getUserAgentStylesheet());
}
-------------
PR Review Comment: https://git.openjdk.org/jfx/pull/2236#discussion_r3751718897