[Kst] Strange problem using the change data file tool

George Staikos staikos at kde.org
Wed Jan 25 21:39:30 CET 2006

On Wednesday 25 January 2006 12:39, Brisset, Nicolas wrote:
> > I have a problem which is driving me crazy: I have
> > implemented a datasource for an internal format, and it works
> > very well with the datawizard or the data manager. However,
> > when I use d2asc or the "Change data file" tool, even though
> > the plugin is called correctly, for some reason kst
> > complains. D2asc says "d2asc error: file enreg.res.B has no
> > data" and the GUI says "Impossible to load data file" (or
> > something equivalent, I have it in French :-)).
> > I'm really wondering why there is a difference here ??? Any
> > hint as to where the problem could lie would be greatly appreciated.
> OK, I think I know :-) The problem is the following: as the constructor
> is sometimes called too often (the datawizard calls it twice I think,
> and reload a lot of times) and this can be very long according to what
> it does. 

   You might want to consider using a flyweight pattern then.  Store your 
variables internally in a cache (singleton controlled) and avoid 

> So, I used a trick. Only the beginning of the data file is 
> parsed in the constructor, and in the first call to update() I really
> parse the whole file and set the number of frames > 0. I'd bet that in
> the change data file tool and d2asc, update() is never called !

   Maybe, but it will never be called from change data file.  d2asc is 
different and can call it.

> Now, there are a few options:
> 1) these calls are added in these two places and possibly others (my
> preferred)

   Only one of those will get it, if ever.

> 2) I change the behavior of my datasource so that it scans the whole
> file right at the beginning (but I fear users will complain)

   Flyweight will help with this.

> 3) we find a way to reduce the number of calls to datasource
> constructors and 2) becomes acceptable (but this will surely take more
> time)

   May not happen due to the desire to auto-detect files.

George Staikos
KDE Developer				http://www.kde.org/
Staikos Computing Services Inc.		http://www.staikos.net/

More information about the Kst mailing list