Returning to the race conditions question, I would like to note that having somethig like waitParsingFinished() might help. This can be called before rebuilding project tree. However, while waiting for empty parsing queue is obvious and simple, that does not help much because events that drive Info* objects updates are asynchronous. If one would have a centralized place for that, then it would be possible to check _its_ queue. Perhaps yet anothe thread that only installs parsing results (By the way what does mean the comment to parsingComplete() event: ".. ownership transfered to ... slots(s)". Slots? Which one will be an owner? A separate installThread would sort it out). Without such mechanism, call to buildProjectTree() in projectOpen() is nearly useless.
On September 26th, 2012, 9:12 p.m., Eugene Shalygin wrote:
Review request for Kile.
By Eugene Shalygin.
Updated Sept. 26, 2012, 9:12 p.m.
Kile shedules parsing of all projet items when it opens a project. But because Manager::m_projects does not contain currently loading project at that time, Manager can not resolve projet items to documents and parsing does not happen.
This patch adds curently parsing project to m_projects collection before invoking projectOpenItem() and thus parsing goes. Then we crate Info* object for each project item (if it does not exist) and sneding it to parsing.
In the next step, in Manager::handleParsingComplete(), TextInfo object is determined via opened documents list, as I understood. To install results for all project items, the patch adds a second branch that determines TextInfo object via KileProjectItem::getInfo() and the item is accessed via Manager::itemFor() (that is why project must be added to m_projects before parsing)
Also the patch changes Info* classes in a way that makes possible to parse files without loading them into KatePart, i.e. without Document object creation. This speeds up project loading. At least on my machine before most of the time was spent in spell checker initialization. We do not need a spell checker for parsing :). To parse a file we use a tiny helper function that loads file contents (getFileContents() in anonymous namespace, parserthread.cpp).
Then it tries to fix a race between parsing and cleaning of Info object by separating the cleaning code into cleanInfo() method and calling it from installParserResults()
With these changes completion works for all bib items and labels in project even if these files are not opened.
- src/parser/latexparser.cpp (ea0ae0b)
- src/parser/parserthread.h (c41123b)
- src/parser/parserthread.cpp (ad38819)
- src/kiledocmanager.cpp (1d652c1)
- src/documentinfo.cpp (2c3a3bb)
- src/documentinfo.h (27ad09f)