Thread: Disapearing CSS
View Single Post
Old 03-25-2015, 02:31 PM   #66
KevinH
Sigil Developer
KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.KevinH ought to be getting tired of karma fortunes by now.
 
Posts: 8,807
Karma: 6000000
Join Date: Nov 2009
Device: many
Quote:
I still haven't figured out how the Create HTML TOC impacts this but I think this should do the trick since it makes the newly added css file act just like one loaded from an original epub.
FWIW, there is a small gap/race in the TextResource.cpp code between when SetText() is called the first time if it has to cache the text to be loaded because it is not in the GUI thread. It will automatically load the cache into the QTextDocument after a single-shot timer expires when we are back in the GUI thread.

But if a call to SaveToDisk (such as doing a File->SaveAs) is made during that interval it will incorrectly read from the QTextDocument (which is empty because it was waiting to be loaded!) and writing it to disk resulting in the disappearing file.

Technically it could happen to any text based resource (OPF, XHTML, CSS, etc) but initial loading was always done so all you were losing might have been the difference between it and its cache if anything at all.

So I have made an additional change to try to close that tiny hole in Sigil master so we are not bitten by this. It was the same bug that made font url's not be properly updated in CSS files too.

Thanks to all for reporting the bug so we could get this tracked down.

Kevin

Last edited by KevinH; 03-25-2015 at 03:35 PM.
KevinH is offline   Reply With Quote