[wx-dev] wxRichTextCtrl GetStyle() bug?

Tom Gersic wxdev at teleologic.net
Wed Jan 24 09:29:26 PST 2007


Hi Julian,

Thanks for offering to take a look. I sent out an email a little bit 
after this one with a link to an example program that reproduces the 
problem. Let me know if that one's enough for you to look at. Otherwise, 
I'll take a look at modifying the wxRichTextCtrl sample to show the issue.

I also submitted a bug report with a link to my sample here:
https://sourceforge.net/tracker/?func=detail&atid=109863&aid=1643619&group_id=9863

Thanks for your help!
Tom

Julian Smart wrote:
> Hi Tom,
>
> Sorry about this, I don't have any information about it but if you 
> manage to patch the wxRichTextCtrl sample to make it easy to 
> reproduce, I'll definitely give it a whirl in the debugger to see if I 
> can spot the problem.
>
> Thanks,
>
> Julian
>
> Tom Gersic wrote:
>> Hi,
>>
>> I think there may be a bug with the wxRichTextCtrl GetStyle() 
>> command, but I can't quite isolate it. What I'm trying to do is to 
>> look at a particular location in the text (say, character 40), and 
>> check whether the wxTEXT_ATTR_URL is set at that location. If it is 
>> set, I want to find where that flag starts and ends (i.e. the 
>> beginning and end of the link). So, I'm simply setting up a loop to 
>> search for the start position of the link:
>>
>>        //for the purposes of this email, assume that characters 20 
>> through 50 have wxTEXT_ATTR_URL set
>>        int startLocation = 40;
>>        wxRichTextAttr attr;
>>        daTextCtrl->GetStyle(startLocation, attr);
>>
>>        while(attr.HasFlag(wxTEXT_ATTR_URL) && startLocation > 0)
>>        {
>>            startLocation--;
>>            daTextCtrl->GetStyle(startLocation, attr);
>>        }
>>
>>        wxMessageBox(wxString::Format("%d",startLocation));          
>> Now, I know for a fact that the link starts at character 20, and 
>> extends to character 50, so startPosition *should* equal 20, but it 
>> always goes through the loop exactly once, and comes back with (in 
>> this instance) 19. If I add a watch for attr.HasFlag, it does indeed 
>> return true the first time and false the second time I check....even 
>> if I don't subtract 1 from startLocation. So, for instance, if I do 
>> this twice...
>>
>> daTextCtrl->GetStyle(startLocation, attr);
>> attr.HasFlag(wxTEXT_ATTR_URL) ;
>>
>> ...the first time it will return true, and the second time it will 
>> return false.
>>
>> What's going on here?
>>
>> Thanks,
>> Tom
>>
>>
>> ---------------------------------------------------------------------
>> To unsubscribe, e-mail: wx-dev-unsubscribe at lists.wxwidgets.org
>> For additional commands, e-mail: wx-dev-help at lists.wxwidgets.org
>>
>>
>>
>
>




More information about the wx-dev mailing list