| Summary: | NullPointerException in org.eclipse.draw2d.FigureUtilities.setFont | ||||||
|---|---|---|---|---|---|---|---|
| Product: | [Tools] GEF | Reporter: | Heiko Böttger <heiko.boettger> | ||||
| Component: | GEF-Legacy Draw2d | Assignee: | gef-inbox <gef-inbox> | ||||
| Status: | RESOLVED DUPLICATE | QA Contact: | |||||
| Severity: | normal | ||||||
| Priority: | P3 | CC: | nyssen, willem.duminy | ||||
| Version: | unspecified | ||||||
| Target Milestone: | --- | ||||||
| Hardware: | PC | ||||||
| OS: | Windows 7 | ||||||
| Whiteboard: | |||||||
| Attachments: |
|
||||||
Created attachment 224586 [details]
Proposed patch for the problem
This patch assumes that:
a. The solution can be localised to Label
b. It is OK to return a zero dimension if the Label's font is null
The root cause for this was the missing null check in FigureUtilities#setFont(), which has been fixed as part of #430392. Resolving as duplicate. *** This bug has been marked as a duplicate of bug 430392 *** |
Build Identifier: 20100218-1602 at org.eclipse.draw2d.FigureUtilities.setFont(FigureUtilities.java:327) at org.eclipse.draw2d.FigureUtilities.getTextDimension(FigureUtilities.java:87) at org.eclipse.draw2d.FigureUtilities.getTextExtents(FigureUtilities.java:125) at org.eclipse.draw2d.TextUtilities.getTextExtents(TextUtilities.java:57) at org.eclipse.draw2d.Label.calculateTextSize(Label.java:244) at org.eclipse.draw2d.Label.getTextSize(Label.java:457) at org.eclipse.draw2d.Label.getPreferredSize(Label.java:329) at org.eclipse.draw2d.Figure.getPreferredSize(Figure.java:725) Reproducible: Always Steps to Reproduce: 1. Create a Label 2. call label.getPreferredSize() 3. call invalidate the label by calling label.revalidate() or label.invalidate() 4. call label.getPreferredSize() to recalculate preferredSize This will always throw a NullPointerException if there isn't a font returned from a parent. Since there is no information that calling getPreferredSize() is not allowed for detached figure, I think this is a bug. Testcase: public void test_getPreferredSizeDetached() { IFigure figure1 = new Label("Hello, World1"); figure1.getPreferredSize(); figure1.invalidate(); figure1.getPreferredSize(); }