View Single Post
Old 04-03-2015, 12:36 PM   #24
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,893
Karma: 6120478
Join Date: Nov 2009
Device: many
Hi Camelot,

Well I found the problem. By doing the merges so fast, you can end up with stale data in the BookBrowser (the widget you posted a graphic of) and stale data in the FolderKeeper m_Resources hash (the universal list of all resources available).

Randomly a Qt garbage collection thread deletes the resource but the signal that tells the FolderKeeper to update itself (remove the resource from its m_Resources hash) has not reached it yet. The second merge then hits this stale info (or some other action that wants the list of all available html resources).

The following patch fixes this on my Sigil master and should work exactly the same (but with a large offset in line) in Sigil 0.8.5 source as well when applied at the end of the MergeResources routine in Book.cpp.

The recent fix for closing Tabs when deletes are done may have exacerbated this by disconnecting the signal from the underlying resource when closing the tab but given the resource was deleted it should not have mattered.

For BookManipulation/Book.cpp

Code:
@@ -903,6 +903,9 @@ Resource *Book::MergeResources(QList<Resource *> resources)
         sink_html_resource.SetText(new_source);
         // Now safe to do the delete
         foreach(Resource * source_resource, resources) {
+            // Need to alert FolderKeeper that these are going away to properly update its
+            // m_Resources hash to prevent stale values from deleted resources hanging around
+            m_Mainfolder.RemoveResource(*source_resource);
             source_resource->Delete();
         }
     }
KevinH is offline   Reply With Quote