On Thu, 11 Jan 2024 20:13:09 GMT, Marius Hanl <mh...@openjdk.org> wrote:

> For some reason the `skinProperty` did not allow to set a new skin when it is 
> the same class as the previous one.
> This leads to multiple issues:
> 1. When creating a new skin (same class as previous), the skin will likely 
> install listener but is then rejected when setting it due to the 
> `skinProperty` class constraint
> -> `PopupControl` is in a weird state as the current skin was not disposed 
> since it is still set, although we already created and 'set' a new skin
> 2. A skin of the same class can behave differently, so it is not really valid 
> to reject a skin just because it is the same class as the previous
> -> Just imagine we have the following skin class
> 
> class MyCustomSkin<C extends PopupControl> extends Skin<C> {
>     public MyCustomSkin(C skinnable, boolean someFlag) { ... }
> }
> 
> Now if we would change the skin of the `PopupControl` two times like this:
> 
> popup.setSkin(new MyCustomSkin(popup, true));
> popup.setSkin(new MyCustomSkin(popup, false));
> 
> The second time the skin will be rejected as it is the same class, although I 
> may changed the skin behaviour, in this case demonstrated by a boolean flag 
> for showing purposes.
> 
> This is the same issue and fix as done for `Control` in 
> [JDK-8276056](https://bugs.openjdk.org/browse/JDK-8276056) (PR: 
> https://github.com/openjdk/jfx/pull/806)

Marked as reviewed by angorya (Reviewer).

I think the proposed fix is correct.  I've tried to re-load skin via CSS (see 
https://github.com/andy-goryachev-oracle/Test/blob/main/src/goryachev/bugs/PopupControl_SetSkin_8323615.java
 ) and it does seem to reload correctly, as far as I can tell.

Loading fails without the fix, as expected.

Still, i would like a second pair of eyes to look at this, if possible.

modules/javafx.controls/src/test/java/test/javafx/scene/control/PopupControlTest.java
 line 680:

> 678:         assertNotEquals("New skin was not set", oldSkin, newSkin);
> 679:     }
> 680: 

minor: please remove extra newline, I'll reapprove if you choose to make the 
change

-------------

PR Review: https://git.openjdk.org/jfx/pull/1331#pullrequestreview-1818950331
PR Comment: https://git.openjdk.org/jfx/pull/1331#issuecomment-1889873614
PR Review Comment: https://git.openjdk.org/jfx/pull/1331#discussion_r1450870863

Reply via email to