| Summary: | Pattern is not disposed after usage in SWTGraphics class | ||
|---|---|---|---|
| Product: | [Tools] GEF | Reporter: | Vijay Raj <vijay.rajonline> |
| Component: | GEF-Legacy Draw2d | Assignee: | gef-inbox <gef-inbox> |
| Status: | RESOLVED INVALID | QA Contact: | |
| Severity: | critical | ||
| Priority: | P3 | CC: | aboyko, hudsonr, nyssen |
| Version: | 3.6 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
|
Description
Vijay Raj
Vijay, on which class are you calling that method? (In reply to comment #1) > Vijay, on which class are you calling that method? Either ScaledGraphics or SWTGraphics instance which ever comes in IFigure.paintFigure(Graphics graphics) method accordingly... ScaledGraphics.setBackgroundPattern(Device device, int x1, int y1, int x2, int y2, Color color1, Color color2) method delegates the call to SWTGraphics.setBackgroundPattern(Device device, int x1, int y1, int x2, int y2, Color color1, Color color2) hence you can say that the problem is in SWTGraphics.setBackgroundPattern(Device device, int x1, int y1, int x2, int y2, Color color1, Color color2) method... Vijay, think this might be an invalid bug. There is only setBackgroundPattern(Pattern) methiods on Graphics class and SWTGraphics, which means is up to the client to create and dispose patterns. Same as colors, fonts, images and anything else requiring platform resource. (In reply to comment #3) > Vijay, think this might be an invalid bug. > > There is only setBackgroundPattern(Pattern) methiods on Graphics class and > SWTGraphics, which means is up to the client to create and dispose patterns. > Same as colors, fonts, images and anything else requiring platform resource. Thats correct in case of SWTGraphics.setBackgroundPattern(Pattern) or ScaledGraphics.setBackgroundPattern(Pattern) the user has to create the Pattern and he alone is responsible for disposing it... But in ScaledGraphics we can not use setBackgroundPattern(Pattern) ,because we have to compensate for scaling, instead we should use setBackgroundPattern(Device device, int x1, int y1, int x2, int y2, Color color1, Color color2) which compensates for scaling public void setBackgroundPattern(Device device, int x1, int y1, int x2, int y2, Color color1, Color color2) { int x1s = (int) (Math.floor(x1 * zoom + fractionalX)); int y1s = (int) (Math.floor(y1 * zoom + fractionalY)); int x2s = (int) (Math.floor(x2 * zoom + fractionalX)); int y2s = (int) (Math.floor(y2 * zoom + fractionalY)); graphics.setBackgroundPattern(new Pattern(device, x1s, y1s, x2s, y2s, color1, color2)); } But as you can see from above code it creates a Pattern class which will never get disposed since this method calls the actual setBackgroundPattern(Pattern) method, which assumes that the pattern instance has been sent by the user and he is responsible for the disposal!!!! (In reply to comment #3) > Vijay, think this might be an invalid bug. > > There is only setBackgroundPattern(Pattern) methiods on Graphics class and > SWTGraphics, which means is up to the client to create and dispose patterns. > Same as colors, fonts, images and anything else requiring platform resource. Same is the case (In reply to comment #4) > (In reply to comment #3) > > Vijay, think this might be an invalid bug. > > > > There is only setBackgroundPattern(Pattern) methiods on Graphics class and > > SWTGraphics, which means is up to the client to create and dispose patterns. > > Same as colors, fonts, images and anything else requiring platform resource. > > Thats correct in case of SWTGraphics.setBackgroundPattern(Pattern) or > ScaledGraphics.setBackgroundPattern(Pattern) the user has to create the Pattern > and he alone is responsible for disposing it... > > But in ScaledGraphics we can not use setBackgroundPattern(Pattern) ,because we > have to compensate for scaling, instead we should use > setBackgroundPattern(Device device, int x1, int y1, int x2, int y2, Color > color1, Color color2) which compensates for scaling > > public void setBackgroundPattern(Device device, int x1, int y1, int x2, int y2, > Color color1, Color color2) > { > int x1s = (int) (Math.floor(x1 * zoom + fractionalX)); > int y1s = (int) (Math.floor(y1 * zoom + fractionalY)); > int x2s = (int) (Math.floor(x2 * zoom + fractionalX)); > int y2s = (int) (Math.floor(y2 * zoom + fractionalY)); > graphics.setBackgroundPattern(new Pattern(device, x1s, y1s, x2s, y2s, > color1, color2)); > } > > But as you can see from above code it creates a Pattern class which will never > get disposed since this method calls the actual setBackgroundPattern(Pattern) > method, which assumes that the pattern instance has been sent by the user and > he is responsible for the disposal!!!! Same is the case with SWTGraphics.setBackgroundPattern(Device device, int x1, int y1, int x2, int y2, Color color1, Color color2) (In reply to comment #5) > Same is the case with SWTGraphics.setBackgroundPattern(Device device, int x1, > int y1, int x2, int y2, Color color1, Color color2) There is no such method, see for yourself: http://dev.eclipse.org/viewcvs/index.cgi/org.eclipse.gef/plugins/org.eclipse.draw2d/src/org/eclipse/draw2d/SWTGraphics.java?view=markup&root=Tools_Project If you want your patterns to scale, you shouldn't be using ScaledGraphics. SWTGraphics also support scaling, but in a different way that causes patterns to scale for "free". (In reply to comment #7) > If you want your patterns to scale, you shouldn't be using ScaledGraphics. > SWTGraphics also support scaling, but in a different way that causes patterns > to scale for "free". Sorry Randy ,my mistake ,please make it an invalid bug... some confusion between my version of draw2d and the actual draw2d... (yes thats a real pain, keeping my own version but what to do i needed org.eclipse.gmf.runtime.draw2d.ui classes without any gmf dependencies and my own requirements) And sorry again for wasting your valuable time... Resoving invalid due to last comment. |