Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 A bug in Turing
Index -> General Programming
View previous topic Printable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Insectoid




PostPosted: Sun May 21, 2017 8:54 pm   Post subject: A bug in Turing

I've been using Turing for nine years now and today hunter2 and I found our first bug in the language itself! Neat stuff! Discussion can be found here: http://compsci.ca/v3/viewtopic.php?p=291034

The bug is with Sprites and View.Set. If you change the size of the run window after creating a sprite, that sprite will be automatically freed. Any attempt to use that sprite will crash the program. Here's a program that causes it:

code:
var pic := Pic.FileNew ("image.bmp")
var Ball := Sprite.New (pic)
Sprite.Show (Ball) %this line executes fine
View.Set ("graphics:800;700")
Sprite.Show (Ball) %this line fails


The following also fails:

code:

View.Set ("graphics:800;700")
var pic := Pic.FileNew ("image.bmp")
var Ball := Sprite.New (pic)
Sprite.Show (Ball) %this line executes fine
View.Set ("graphics") %resets to default 640x480
Sprite.Show (Ball) %this line fails


The following code executes with no errors:

code:
View.Set ("graphics:800;700")
var pic := Pic.FileNew ("image.bmp")
var Ball := Sprite.New (pic)
Sprite.Show (Ball) %this line executes fine
View.Set ("graphics:800;700") %window size hasn't changed
Sprite.Show (Ball) %this line no longer fails


I suspect that when a sprite is created, it is bound to the active window that created it. Resizing the window does not actually resize, but destroys the original and creates a new one with the new dimensions. The sprites can no longer draw to the original window, but only knows one error ('sprite was freed') and returns that. Or maybe destroying the window recursively destroys everything attached to it. We'll have to poke through the source code (well, somebody will, and it won't be me) to find out for sure what's going on. I can't find anything in the documentation for View.Set, Sprite, or Window that would explain this behavior.
Sponsor
Sponsor
Sponsor
sponsor
Display posts from previous:   
   Index -> General Programming
View previous topic Tell A FriendPrintable versionDownload TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 1 Posts ]
Jump to:   


Style:  
Search: