Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / CloneSprite using a sprite id created with LoadSprite("imagefile.png") will crash

Author
Message
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 20th Sep 2013 17:24
An issue was raised in the Google list that pointed out this problem.

Use any image you want in the following code:


The code as it is entered above will cause the app to hang and crash when you exit it.

This version does not:


It appears that the cleanup done by the AppGameKit engine at the end does not handle the first case well. It deletes the original sprite and the image that was created for it and then crashes when it tries to do the same with the cloned sprite.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 20th Sep 2013 17:45
Fixed the title for you AL

I don't use loadSprite but it's a nasty little bug for sure.

You can never have too much sausage
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 20th Sep 2013 18:01
Thank you. I hate making that kind of mistake and being misleading.

Well, the bug has been reported everywhere it can be (including confirming it in the site created for CTs, which everyone is welcome to visit).

At this stage, the best we can do is warn not to use that combination.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 20th Sep 2013 21:20
I had no idea that command existed. Seems redundant when you can just use CreateSprite(LoadImage("myImage.png"))
What an odd command...

Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 21st Sep 2013 12:18 Edited at: 21st Sep 2013 12:19
if you have uniqe sprites LoadSprite is very useful because you need only memory the sprite id and later the deletesprite command will delete this image too.

@Naphier
Quote: "CreateSprite(LoadImage("myImage.png"))"

you cant free the image because you did not memory the id.
but the automatic will do it for you at end.
LoadSprite know it had allocate one image and it will be
freed at deletesprite.
Naphier
13
Years of Service
User Offline
Joined: 2nd Oct 2010
Location: St Petersburg, Florida
Posted: 21st Sep 2013 15:39
I see. That makes some sense.

Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 21st Sep 2013 19:48
Quote: "you can't free the image because you did not memory the id."

You can get the sprite's image ID with GetSpriteImageID()
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 21st Sep 2013 19:52 Edited at: 21st Sep 2013 19:55
Quote: "You can get the sprite's image ID with GetSpriteImageID()"

EDIT: The GetSpriteImageID() command returns zero when the sprite is created with LoadSprite.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 22nd Sep 2013 02:19 Edited at: 22nd Sep 2013 02:20
Quote: "EDIT: The GetSpriteImageID() command returns zero when the sprite is created with LoadSprite."

Good to know, but the point was how to delete the image if you didn't use loadsprite, but instead used CreateSprite(LoadImage("myImage.png")), which doesn't return the image ID.

'cos apparently LoadSprite has a bug in it
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 22nd Sep 2013 03:08
Quote: "'cos apparently LoadSprite has a bug in it"

Or a very limited use and should have warnings about what it should not be used with, like CloneSprite and GetSpriteImageID.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master

Login to post a reply

Server time is: 2024-05-09 07:11:36
Your offset time is: 2024-05-09 07:11:36