Thread: Disapearing CSS
View Single Post
Old 03-25-2015, 01:29 PM   #62
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,560
Karma: 5703586
Join Date: Nov 2009
Device: many
Quote:
Originally Posted by Turtle91 View Post


I'm not able to get it to recreate with those steps...

HOWEVER!!

I went in and removed the sgc-toc.css file that I had stored in the preferences folder this morning....and then it DID confirm!!

So, somewhere between creating a new sgc-toc.css file vs. using a templated one??
Hmm perhaps there are two bugs here or one related bug.

The following patch fixed the bug for me but I do not have a recent 0.8.4 tree sitting around to test with. My version of Sigil is based on my git master and it is much different from Sigil 0.8.4.

So DiapDealer (or anyone else who builds their own), if you get a free moment and have a 0.8.4 tree around someplace, please try the following patch and see if it fixes the bug for you.

Code:
--- src/Sigil/MainUI/BookBrowser.cpp~	2015-02-28 16:48:28.000000000 -0500
+++ src/Sigil/MainUI/BookBrowser.cpp	2015-03-25 13:16:19.000000000 -0400
@@ -638,7 +638,11 @@
             }
         } else {
             // TODO: adding a CSS file should add the referenced fonts too
-            m_Book->GetFolderKeeper().AddContentFileToFolder(filepath);
+            Resource & resource = m_Book->GetFolderKeeper().AddContentFileToFolder(filepath);
+            if (resource.Type() == Resource::CSSResourceType) {
+                CSSResource *css_resource = qobject_cast<CSSResource *> (&resource);
+                css_resource->InitialLoad();
+            }
         }
 
         added_files.append(filepath);
The patch forces the CSSResource to actually load the file into its own QTextDocument.

This would have been done for you if you used the Tab to open the new .css file and changed it. It is always done for every css file for that is imported by loading an epub. But the AddExisting path did not do this, which is what caused the bug. 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.

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