This Bugzilla instance is a read-only archive of historic NetBeans bug reports. To report a bug in NetBeans please follow the project's instructions for reporting issues.

Bug 153014 - HtmlRenderer may produce NullPointerException
Summary: HtmlRenderer may produce NullPointerException
Status: RESOLVED FIXED
Alias: None
Product: platform
Classification: Unclassified
Component: Window System (show other bugs)
Version: 6.x
Hardware: All All
: P3 blocker (vote)
Assignee: David Simonek
URL:
Keywords: SIMPLEFIX
Depends on:
Blocks:
 
Reported: 2008-11-12 08:26 UTC by toker5
Modified: 2009-02-19 22:53 UTC (History)
0 users

See Also:
Issue Type: DEFECT
Exception Reporter:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description toker5 2008-11-12 08:26:40 UTC
By using a custom ViewTabDisplayerUI, I managed to have the HtmlRenderer's _renderPlainString() method produce
NullPointerExceptions when the tabs got too narrow to hold its title. The reason is that
HtmlRenderer#_renderPlainString() uses the result of g.getClip() as an argument to the constructor of Area on line 407:

Shape shape = g.getClip();

if (s != null) {
    Area area = new Area(shape);
    area.intersect(new Area(new Rectangle(x, y, w, h)));
    g.setClip(area);
} else {
    g.setClip(new Rectangle(x, y, w, h));
}

g.drawString("...", x, y);
g.setClip(shape);

In my ViewTabDisplayerUI I paint to the graphics context of a BufferedImage (for transparency effects), and because of
that, no clip is set, i.e. g.getClip() returns null. There's no problem to avoid this issue, but HtmlRenderer should
definitely check if the clip is null.

This might also be an issue in other methods of HtmlRenderer (not tested).
Comment 1 David Simonek 2008-12-03 16:22:30 UTC
thanks for finding, fixed in #a90b6c79c3f7
Comment 2 Quality Engineering 2008-12-05 05:59:18 UTC
Integrated into 'main-golden', will be available in build *200812050201* on http://bits.netbeans.org/dev/nightly/ (upload may still be in progress)
Changeset: http://hg.netbeans.org/main/rev/a90b6c79c3f7
User: Dafe Simonek <dsimonek@netbeans.org>
Log: #153014: count with possibility that graphics.getClip() can return null