[squeak-dev] OrderedCollection bug?

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

[squeak-dev] OrderedCollection bug?

Steven W Riggins
Hi there!

We're running Sophie in a 3.8 image, and ran into a fairly nasty  
OrderedCollection bug.  I've not tried to replicate this in later  
images.

o := OrderedCollection new.
o add: true beforeIndex: 2.

If you do this, the resulting collection is (nil)

No error, and true is not in the collection.

Can someone verify if this still exists, or what the proper behavior is?

Back Story:  When "saving as" our page templates, the code determines  
that some actions are not needed, but it still writes them into the  
new collection based on their old index.  So you end up with a nil  
object in the collection, missing the object you intended to be there,  
and a silent failure to boot.

We'll clean up our usage of OrderedCollection, but shouldn't this at  
least throw an error?

Steve

Reply | Threaded
Open this post in threaded view
|

[squeak-dev] Re: OrderedCollection bug?

Andreas.Raab
I've posted a fix at:

   http://bugs.squeak.org/view.php?id=7121

Cheers,
   - Andreas


Steven W Riggins wrote:

> Hi there!
>
> We're running Sophie in a 3.8 image, and ran into a fairly nasty
> OrderedCollection bug.  I've not tried to replicate this in later images.
>
> o := OrderedCollection new.
> o add: true beforeIndex: 2.
>
> If you do this, the resulting collection is (nil)
>
> No error, and true is not in the collection.
>
> Can someone verify if this still exists, or what the proper behavior is?
>
> Back Story:  When "saving as" our page templates, the code determines
> that some actions are not needed, but it still writes them into the new
> collection based on their old index.  So you end up with a nil object in
> the collection, missing the object you intended to be there, and a
> silent failure to boot.
>
> We'll clean up our usage of OrderedCollection, but shouldn't this at
> least throw an error?
>
> Steve
>
>


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] OrderedCollection bug?

timrowledge
In reply to this post by Steven W Riggins
Just as #add:before: raises an exception when the second arg is not in  
the collection (indirectly, since #find: does not find the second arg)  
add:beforeIndex: should raise an exception if there is no valid index  
given as the second arg. Though to be honest I really don't think  
OrderedCollection should even implement add:beforeIndex: &  
add:afterIndex:. It's just.... yuck. All the usages I can spot are  
simply poor algorithms that ought to be done properly.

tim
--
tim Rowledge; [hidden email]; http://www.rowledge.org/tim
Oxymorons: Act naturally



Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] Re: OrderedCollection bug?

Steven W Riggins
In reply to this post by Andreas.Raab
Thanks! Was along the lines I was looking at, but I was not sure of  
the intended behavior.


On Jul 15, 2008, at 11:15 PM, Andreas Raab wrote:

> I've posted a fix at:
>
>  http://bugs.squeak.org/view.php?id=7121
>
> Cheers,
>  - Andreas
>
>
> Steven W Riggins wrote:
>> Hi there!
>> We're running Sophie in a 3.8 image, and ran into a fairly nasty  
>> OrderedCollection bug.  I've not tried to replicate this in later  
>> images.
>> o := OrderedCollection new.
>> o add: true beforeIndex: 2.
>> If you do this, the resulting collection is (nil)
>> No error, and true is not in the collection.
>> Can someone verify if this still exists, or what the proper  
>> behavior is?
>> Back Story:  When "saving as" our page templates, the code  
>> determines that some actions are not needed, but it still writes  
>> them into the new collection based on their old index.  So you end  
>> up with a nil object in the collection, missing the object you  
>> intended to be there, and a silent failure to boot.
>> We'll clean up our usage of OrderedCollection, but shouldn't this  
>> at least throw an error?
>> Steve
>
>


Reply | Threaded
Open this post in threaded view
|

Re: [squeak-dev] OrderedCollection bug?

Steven W Riggins
In reply to this post by timrowledge
Indeed.  I suspect this is likely the issue.  It was initially done  
when something is cut out of a list, the undo can put it back.  Likely  
it should recall which object it was after, stick it back in and resort.

The bug we ran into was when adding an action, the action list was  
empty, but a method synthesized a list composed of the frame and  
template frame, which was not empty, so then it decided to insert  
before index 3.  That code has been changed to just do an add:

Steve

On Jul 15, 2008, at 11:24 PM, tim Rowledge wrote:

> Just as #add:before: raises an exception when the second arg is not  
> in the collection (indirectly, since #find: does not find the second  
> arg) add:beforeIndex: should raise an exception if there is no valid  
> index given as the second arg. Though to be honest I really don't  
> think OrderedCollection should even implement add:beforeIndex: &  
> add:afterIndex:. It's just.... yuck. All the usages I can spot are  
> simply poor algorithms that ought to be done properly.
>
> tim
> --
> tim Rowledge; [hidden email]; http://www.rowledge.org/tim
> Oxymorons: Act naturally
>
>
>