On 12/04/2016 11:35 AM, Pascal wrote:
> I used a vector of sprites, the private Sprite_Type is the cursor type of the 
> vector.
> After I created 2 sprites SP1 and SP2 of Sprite_Type and I deleted SP1 with 
> no error then I deleted SP2 with the error:
> raised CONSTRAINT_ERROR : 
> Gnoga.Gui.Element.Canvas.Context_2D.Sprite.Sprite_Lists.Element: Position 
> cursor is out of range
> I can't get SP2 element before deleting it.
>
> Is it cursor tampering when deleting SP1?
> If yes, I don't understand actually why.
> Any clue?
> Thus what should I take for Sprite_Type?

I've never really understood what a cursor is supposed to be for a vector. Since
it should be named Unbounded_Arrays, the idea should be that you access elements
through indices. Anyway, GNAT 4.9 implements Cursor as

   type Cursor is record

      Container : Vector_Access;

      Index     : Index_Type := Index_Type'First;

   end record;

So I'd guess when you delete SP1, the Index in SP2 becomes invalid. Not very
useful, and we shouldn't have to look in the private part to understand how it
works. You'd probably do better with a list, since Cursor would then be an
access to a list node, and not change when nodes are inserted or deleted.

-- 
Jeff Carter
"I snapped my chin down onto some guy's fist and
hit another one in the knee with my nose."
Play It Again, Sam
129



------------------------------------------------------------------------------
_______________________________________________
Gnoga-list mailing list
Gnoga-list@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/gnoga-list

Reply via email to