Code::Blocks Forums

Developer forums (C::B DEVELOPMENT STRICTLY!) => Development => Topic started by: rickg22 on January 07, 2006, 07:52:51 pm

Title: Bug in Codecompletion cache
Post by: rickg22 on January 07, 2006, 07:52:51 pm
Nativeparser.cpp:465

The last 1024 bytes never get written because the file's closed prematurely.

Before:
Code
    wxFileOutputStream fs(f);
    wxBufferedOutputStream fb(fs);
    bool result = parser->WriteToCache(&fb);
    f.Close();

After:
Code
    wxFileOutputStream fs(f);
    wxBufferedOutputStream *fb = new wxBufferedOutputStream(fs);
    // write cache file
    bool result = parser->WriteToCache(fb);
    delete fb;
    f.Close();

I'd commit, but In the middle of a redesign :mrgreen:
Title: Re: Bug in Codecompletion cache
Post by: killerbot on January 07, 2006, 07:56:41 pm
how come the dynamic allocation performs ok, and the static one doesn't ??
Title: Re: Bug in Codecompletion cache
Post by: thomas on January 07, 2006, 08:10:22 pm
Because the file is explicitely (and unnecessarily) closed. This happens before the stream is destroyed, so the stream is unable to write the last chunk to disk.
Title: Re: Bug in Codecompletion cache
Post by: rickg22 on January 07, 2006, 08:13:38 pm
oops, i just realized it was I who added that Close() in the first place :oops: - Now i wonder if that close was present in current SVN anyway. :roll: