| Summary: | StyledTextRenderer.hasLink() uses invalid indexing if no ranges array is defined | ||
|---|---|---|---|
| Product: | [Eclipse Project] Platform | Reporter: | Pekko Tiitto <tiittop> |
| Component: | SWT | Assignee: | Felipe Heidrich <eclipse.felipe> |
| Status: | RESOLVED FIXED | QA Contact: | |
| Severity: | minor | ||
| Priority: | P3 | CC: | eclipse.felipe |
| Version: | 4.0 | ||
| Target Milestone: | 3.7 M2 | ||
| Hardware: | PC | ||
| OS: | Windows XP | ||
| Whiteboard: | |||
You are right, thank you for the patch. Fixed in HEAD |
Build Identifier: I20100608-0911 I have implemented a org.eclipse.swt.custom.LineStyleListener to style my text (links, different colors), and for each line there can be 0-N StyleRanges. If I do not specify the LineStyleEvent.ranges array, then changing the mouse cursor when the mouse cursor is over a link doesn't always work correctly. I think the problem is in the method org.eclipse.swt.custom.StyledTextRenderer.hasLink(int): ... for (int i = 0; i < styles.length; i++) { if (styles[i].start <= offset && offset < styles[i].start + styles[i].length && styles[i >> 1].underline && styles[i >> 1].underlineStyle == SWT.UNDERLINE_LINK) { return true; } } ... And more specifically in the latter two cases where the array 'styles' is indexed ("styles[i >> 1]"). I think those should be replaced with "styles[i]". If I define the LineStyleEvent.ranges array then mouse cursor is changed correctly. Reproducible: Always