Hi Sergey,
On 12-Sep-18 2:39 AM, Sergey Bylokhov wrote:
Hi, Prasanta.
On 07/09/2018 03:57, Prasanta Sadhukhan wrote:
Please review a fix for an issue where obtaining baseline for Button
UI in Nimbus L&F results in NPE.
Reason for it is when SynthPanelUI#installDefaults is called during
frame instantiation, it calls SynthPanelUI#updateStyle which sets the
context AND then the style
/private void updateStyle(JPanel c) {//
// SynthContext context = getContext(c, ENABLED);//
// style = SynthLookAndFeel.updateStyle(context, this);//
// }/ > Now, SynthContext.getContext is called with style "null"
as style is
updated after calling getContext.
So, when getBaseline is called and it tries to invoke
context.getStyle().getGraphicsUtils() it causes NPE.
Why SynthLookAndFeel.updateStyle() which is called in
SynthButtonUI.updateStyle(AbstractButton b) did not update the context
which is passed to it? Is it possible that
SynthButtonUI.installDefaults() was not called before getBaseline()?
SynthButtonUI.updateStyle() called from SynthButtonUI.installDefaults()
creates a new context whereas in getBaseline() we again calls
getContext() in l207 which creates a new SynthContext, so the style was
not updated to the context currently being queried in getBaseline()
Regards
Prasanta