| Summary: | restoreState error | ||
|---|---|---|---|
| Product: | [Tools] GEF | Reporter: | Yang Liu <yliu000> |
| Component: | GEF-Legacy Draw2d | Assignee: | gef-inbox <gef-inbox> |
| Status: | RESOLVED WORKSFORME | QA Contact: | |
| Severity: | major | ||
| Priority: | P3 | ||
| Version: | 3.1.1 | ||
| Target Milestone: | --- | ||
| Hardware: | PC | ||
| OS: | Windows 2000 | ||
| Whiteboard: | |||
hmm, possible of the real cause of the problem is:
public void setBackgroundPattern(Pattern pattern) {
currentState.graphicHints |= ADVANCED_GRAPHICS_MASK;
if (currentState.fgPattern == pattern)
^^
return;
currentState.bgPattern = pattern;
if (pattern != null) {
initTransform(true);
gc.setBackgroundPattern(pattern);
}
}
It should be bgPattern!
This was fixed already in the HEAD stream, aka 3.2. |
In org.eclipse.draw2d.SWTGraphics, in my understanding, the graphics state is saved in two places: the underly GC (state.affineMatrix) and the other fields in state (such as bgColor, bgPattern). So when restore state, need to restore both. In current implementation (3.1.1), the restoreState() method is something like this: setAffineMatrix(s.affineMatrix); ... setBackgroundPattern(s.bgPattern); ... So it restore the affineMatrix first. But in setBackgroundPattern(), if the pattern is not null, it will futher do the following: setBackgroundPattern initTransform new Transform() gc.setTransform(transform) Thus change the underlying matrix in the GC again! So after restoreState(), the underlying matrix may not revert back to old state! I was trying a fix to move the "setAffineMatrix(s.affineMatrix)" statement to the end of "restoreState()" method. It seem to work fine.