[8.5.2] EtWindow>>#stsFindItem:clientData:callData: defect

Previous Topic Next Topic
 
classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

[8.5.2] EtWindow>>#stsFindItem:clientData:callData: defect

Richard Sargent
Administrator
I discovered some incorrect code in the 8.5.2 version of EtWindow>>#stsFindItem:clientData:callData:. This code may still be in more recent versions; I have not verified this.

Specifically, if there are no items in the list, you can get an Index Out of Range error.
    index := start := widget selectedItemIndexes isEmpty
        ifTrue: [1]
        ifFalse
: [widget selectedItemIndexes last].
    found
:= nil.
   
[found isNil and: [index < widget itemCount]] whileTrue: [
        index
:= index + 1.
       
((widget getItemAt: index) stsAsString asUppercase wbBeginsWith: string)
            ifTrue
: [found := index]].
    index
:= 0.
   
[found isNil and: [index < start]] whileTrue: [
        index
:= index + 1.
       
((widget getItemAt: index) stsAsString asUppercase wbBeginsWith: string)
            ifTrue
: [found := index]].

In the above code, start is initialized to 1. The first while true skips doing anything, because index > widget itemCount. [There appears to be another error in this block due to the immediate incrementing of the index, meaning it would start at item 2.]

The second while true block tests index against start, which has been initialized regardless of the item count. Consequently, the first iteration through fails. index = 0 and is < start. index is incremented, and the widget is asked for that item, an item which does not exist.


I think this will be reproduceable for you. I was working in a changes browser, using Alt-M-F to remove the methods from the list for the current class. The next class in the list had no methods and the error was triggered. I don't understand why the call was made with the character $m.

The call data for the method was: CwKeyEvent[236,9] state=0 time=1372229956 keycode=109 keysym=109 character=$m



--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.
Reply | Threaded
Open this post in threaded view
|

Re: [8.5.2] EtWindow>>#stsFindItem:clientData:callData: defect

Seth Berman
Thanks Richard,

I have created case 56203 to review and fix this item.

-- Seth

On Wednesday, September 3, 2014 6:30:41 PM UTC-4, Richard Sargent wrote:
I discovered some incorrect code in the 8.5.2 version of EtWindow>>#stsFindItem:clientData:callData:. This code may still be in more recent versions; I have not verified this.

Specifically, if there are no items in the list, you can get an Index Out of Range error.
    index := start := widget selectedItemIndexes isEmpty
        ifTrue: [1]
        ifFalse
: [widget selectedItemIndexes last].
    found
:= nil.
   
[found isNil and: [index < widget itemCount]] whileTrue: [
        index
:= index + 1.
       
((widget getItemAt: index) stsAsString asUppercase wbBeginsWith: string)
            ifTrue
: [found := index]].
    index
:= 0.
   
[found isNil and: [index < start]] whileTrue: [
        index
:= index + 1.
       
((widget getItemAt: index) stsAsString asUppercase wbBeginsWith: string)
            ifTrue
: [found := index]].

In the above code, start is initialized to 1. The first while true skips doing anything, because index > widget itemCount. [There appears to be another error in this block due to the immediate incrementing of the index, meaning it would start at item 2.]

The second while true block tests index against start, which has been initialized regardless of the item count. Consequently, the first iteration through fails. index = 0 and is < start. index is incremented, and the widget is asked for that item, an item which does not exist.


I think this will be reproduceable for you. I was working in a changes browser, using Alt-M-F to remove the methods from the list for the current class. The next class in the list had no methods and the error was triggered. I don't understand why the call was made with the character $m.

The call data for the method was: CwKeyEvent[236,9] state=0 time=1372229956 keycode=109 keysym=109 character=$m



--
You received this message because you are subscribed to the Google Groups "VA Smalltalk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to [hidden email].
To post to this group, send email to [hidden email].
Visit this group at http://groups.google.com/group/va-smalltalk.
For more options, visit https://groups.google.com/d/optout.