Crash with Stage inserts

Confirmed on what I am using,

  • only those 8 lines,

    • Just main.lua running in MAC simulator VERSION (2012.894(2012.8.27)) Mac 10.7.5

    • and on WIN Simulator VERSION (2012.894(2012.7.27)) Windows 7 Pro svc pack 1

    • you cant build for iOS without build.settings and config.lua so on the iPad i use them

I would say that the problem is more complicated than different version of OS,
since it does not work on Mac or Windows or iPad1.

Just to confirm with you,

After the second print statement executed, you still see a white box on the screen?
[import]uid: 106158 topic_id: 33024 reply_id: 131298[/import]

Yep, I still see the white box, and no errors whatsoever.

I assume your config.lua and build.settings are totally “vanilla”? Nothing weird inside them?

Did you try a slightly more simple scenario without the timer and embedded function, like this?

local a = display.newGroup() -- without this line it seems to not crash  
local stage = display.getCurrentStage()  
   
local loo = display.newRect(100,100,100,255)  
   
stage:insert(1, loo)  
print("The Stage Ref is ", stage)  
loo.parent:insert(6, loo)  
print("Loo's parent is ", loo.parent)  

Finally (and this probably isn’t related, but I’m curious), why are you trying to insert an object at position 6 in the hierarchy, when there’s nothing in indexes 2-5? Personally, I never use the strict “index declaration” on inserting into display groups (although it is valid, according to the documentation). I simply add my my objects in the proper bottom-to-top order among layers, and if I need to ever force something to the front or back, I use object:toFront() or object:toBack(). Again, I don’t think this is the cause of your crash, I’m just asking if you have a reason or if this is merely for testing purposes.

Brent

[import]uid: 9747 topic_id: 33024 reply_id: 131302[/import]

I am using a third party library called widget candy mainly for the widgets and windows it allows you to place on screen and edit easily. Since my App allows you to edit and design an interface it needs to be able move or stack widgets from front to back. The library automatically handles all of the ordering by storing a zindex for each Widget.

With a Corona display group the index is used to determine where in the draw stack an object is.

For Instance, adding object to position 1 of a display group means that object is now drawn over the others in the group. Inserting at 1 also moves all of the other members up by 1. This is the same as with the stage which is also a display group. Ultimately, you should be able to insert into any position you want within a display group as it an ordered collection.

If you had a collection of controls all over top of each other and you wanted to put your object in the center of the stack how would you determine where that was simply using toBack or toFront?

[import]uid: 106158 topic_id: 33024 reply_id: 131307[/import]

Yeah, I know how the z-indexing of display groups works. I was just curious what your needs for the specific index declaration was. When I “layer” items in a group, typically I just declare them in bottom-to-top order. But in your case, I see you need very specific control to (perhaps) shift the widgets’ z-index around post-declaration.

Is the error still occurring with the simplified code I suggested? [import]uid: 9747 topic_id: 33024 reply_id: 131313[/import]

I looked at your bug case and the problem is with this line of code:

timer.performWithDelay(3000, function() print(loo.parent) loo.parent:insert(6, loo) end)

In the sample you provided the stage only has two objects and you are now trying to re-insert the object at the 6th position. That is a bug in your code and not in Corona. Corona should have checked for that condition and not crashed. [import]uid: 7559 topic_id: 33024 reply_id: 131325[/import]

Thank you for clarifying this Tom.

[import]uid: 106158 topic_id: 33024 reply_id: 131526[/import]

Thank you for clarifying this Tom.

[import]uid: 106158 topic_id: 33024 reply_id: 131526[/import]