Re: [Vala] Possibly, error in code generator



On 10/12/2007, Jürg Billeter <j bitron ch> wrote:
Hi,

On Mon, 2007-12-10 at 18:22 +0300, Denis Cheremisov wrote:
> The program gives segmentation fault.

FileStream.open is a static method (fopen) that creates and returns a
new FileStream (FILE*).

"new FileStream ()" should be rejected by valac as there is no such
creation method in the FileStream class. It's a bug in valac that it
doesn't complain about this invalid code.

Try something like this:

FileStream file = FileStream.open (filename, "r");

There is another issue with the code: you may not call close() in this
situation as Vala calls close() automatically when the file variable
goes out of scope (or when you explicitly set it to null). I should fix
valac to disallow manual close calls in such cases.

Is it standard .Net to throw an error multiple close calls? Java does not complian...

Maybe GIO will handle this.

Cheers,
Mikkel



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]