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

Summary: HtmlRenderer may produce NullPointerException
Product: platform Reporter: toker5 <toker5>
Component: Window SystemAssignee: David Simonek <dsimonek>
Status: RESOLVED FIXED    
Severity: blocker Keywords: SIMPLEFIX
Priority: P3    
Version: 6.x   
Hardware: All   
OS: All   
Issue Type: DEFECT Exception Reporter:

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