[Sugar-devel] Object Chooser (was Re: Etoys mp3 files)

Bert Freudenberg bert at freudenbergs.de
Wed Jun 6 15:36:57 EDT 2012


On 06.06.2012, at 20:19, Ajay Garg <ajaygargnsit at gmail.com> wrote:

> When a file was checked out from the datastore, an activity needs to delete it when it is done. Etoys deletes the file when the file object is released (using a finalizer). I guess the MPEGPlayer stores only the name, closes the file, and tries to re-open it from the same name. If the original file object has been garbage-collected already, the finalizer will have deleted the file. Thus, trying to re-open it will fail.
> 
> 
> I guess this is what is happening.
> 
> 
> Some thoughts ::
> 
> a)
> So, the reason that things work fine in the case of USB drives, is because there is always a reference to the file by the OS. Thus, the file itself is never deleted.

Yes.


> b)
> More importantly, WHY WOULD MPEGPLAYER NEED TO DELETE THE FILE? CAN THE FILE SIMPLY NOT BE ACCESSED IN A UNIFORM MANNER FROM BOTH JOURNAL AND USB PEN DRIVES?
> As part of this, I tried using the journal file simply (without making its copy). So, now "Rewind" worked. But the next time, "Rewind" did not work, apparently because the file was deleted.
> 
> 
> So,
> WHY WOULD MPEGPLAYER NEED TO DELETE THE FILE? CAN THE FILE SIMPLY NOT BE ACCESSED IN A UNIFORM MANNER FROM BOTH JOURNAL AND USB PEN DRIVES, WITHOUT HAVING THE NEED TO DELETE THE FILE ALTOGETHER?
> 

Because that is how the Sugar datastore works:

http://wiki.sugarlabs.org/go/Development_Team/Low-level_Activity_API#Keeping_and_Resuming

When you call get_filename() on the datastore object, a copy is made by the datastore, which the activity needs to delete.

And it's not the MPEG player which deletes the file, but SugarLauncher.

> On an unrelated note :: Thanks a ton for the tutorials on  squeak. I could finally do some live debugging :D :D
> Thanks again.
> 
> Thanks and Regards,
> Ajay

Hehe. Be careful, you may like what you learn ;)

(in that case, you should maybe get someone to send you to the Smalltalks conference in Argentina in November)

- Bert -
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.sugarlabs.org/archive/sugar-devel/attachments/20120606/3b6f13df/attachment-0002.html>


More information about the Sugar-devel mailing list