CMake project reloading.

Andreas Pakulat apaku at
Wed Feb 3 10:24:11 UTC 2010

On 03.02.10 16:17:36, Olivier J. G. wrote:
> > Hell no. I don't want another beast of the dimension of DUChain for the
> > project tree. David already suggested a viable alternative: Don't store
> > raw pointers to project items anywhere, except in the model itself (and
> > thats not our code). He suggested that everybody else only keep a struct
> > that has the path inside the model and when it tries to access something
> > it fetches the actual item from the model. That way you can do effective
> > null-pointer checks when actually using the item.
> >
> > The other option would be using a ref-counted class instead of raw
> > pointers in the public API everywhere.
> Think about the scenario I'm talking about though. Perhaps locking
> isn't the best solution, I can't say I'm familiar with the internals,
> but take the first solution...
> .cpp file deleted, model starts a reload, BEFORE the model finishes
> reloading, the next file comes around and asks for a proper
> ProjectItem... "Sorry, the file you tried to delete no longer
> exists".... until the project finishes reloading. Admittedly this in
> combination with removeFiles should solve the problem, but still,
> that's definitely gotcha behavior.
> Second solution would have basically the same issue.

No, if the items where ref-counted the second file wouldn't be deleted by
reloading the model. Instead it would be deleted once the code that
actually tries to remove it from the model lets its handle go. This may
cause duplicated items during the whole update-operation, but thats ok

I never was fond of that reload method, IMHO the project managers should be
able to better keep track of things. So if a file X is deleted and removed
from the cmakelists.txt, they wouldn't just drop the whole folder from the
model. Instead they'd parse the updated file and generate some kind of
"difference" between the old and the new state and apply the necessary
deletions/additions of subitems only. Yes this is more complex than a
complete reload, but its (IMHO) also the "right way" to do it.


Things will be bright in P.M.  A cop will shine a light in your face.

More information about the KDevelop-devel mailing list