Author Topic: Bug in Codecompletion cache  (Read 6302 times)

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Bug in Codecompletion cache
« 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:

Offline killerbot

  • Administrator
  • Lives here!
  • *****
  • Posts: 5529
Re: Bug in Codecompletion cache
« Reply #1 on: January 07, 2006, 07:56:41 pm »
how come the dynamic allocation performs ok, and the static one doesn't ??

Offline thomas

  • Administrator
  • Lives here!
  • *****
  • Posts: 3979
Re: Bug in Codecompletion cache
« Reply #2 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.
"We should forget about small efficiencies, say about 97% of the time: Premature quotation is the root of public humiliation."

Offline rickg22

  • Lives here!
  • ****
  • Posts: 2283
Re: Bug in Codecompletion cache
« Reply #3 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: