There was one recent change that could cause an infinite loop but should not.
This is the one I am worrying about
:
https://github.com/Sigil-Ebook/Sigil...afbe68f6c1d6b2
So could you try the following change to see if it helps in any way:
In Sigil/src/ViewEditors/ViewPreview.cpp
Code:
void ViewPreview::CustomSetDocument(const QString &path, const QString &html)
{
if (html.isEmpty()) {
return;
}
m_CustomSetDocumentInProgress = true;
if (!url().isEmpty()) {
// Storing the Caret Location here causes problems as it happens to interfere with later loading
// StoreCurrentCaretLocation();
// To keep memory footprint small, clear any caches when a new page loads
// But in Qt 6.7.0 and later cache clearing became asynchronous requiring a callback
// *before* trying to load anything after a cache clear, otherwise loading
// remote resources fails
// Note: toLocalFile() fails with any custom scheme (ie. our sigil: scheme)
// So convert url to file: scheme to extract the local file
QUrl localurl(url());
localurl.setScheme("file");
localurl.setHost("");
if (localurl.toLocalFile() != path) {
DBG qDebug() << "clearing Preview's httpcache";
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
m_CacheCleared = false;
#endif
page()->profile()->clearHttpCache();
while(!m_CacheCleared) {
qApp->processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers, 50);
}
}
}
Try commenting out the setting of m_CacheCleared to false and commenting out the actual clearing of the cache itself: page()->profile()->clearHttpCache();
In other words make it look like the following:
Code:
void ViewPreview::CustomSetDocument(const QString &path, const QString &html)
{
if (html.isEmpty()) {
return;
}
m_CustomSetDocumentInProgress = true;
if (!url().isEmpty()) {
// Storing the Caret Location here causes problems as it happens to interfere with later loading
// StoreCurrentCaretLocation();
// To keep memory footprint small, clear any caches when a new page loads
// But in Qt 6.7.0 and later cache clearing became asynchronous requiring a callback
// *before* trying to load anything after a cache clear, otherwise loading
// remote resources fails
// Note: toLocalFile() fails with any custom scheme (ie. our sigil: scheme)
// So convert url to file: scheme to extract the local file
QUrl localurl(url());
localurl.setScheme("file");
localurl.setHost("");
if (localurl.toLocalFile() != path) {
DBG qDebug() << "clearing Preview's httpcache";
#if QT_VERSION >= QT_VERSION_CHECK(6, 7, 0)
// m_CacheCleared = false;
#endif
// page()->profile()->clearHttpCache();
while(!m_CacheCleared) {
qApp->processEvents(QEventLoop::ExcludeUserInputEvents | QEventLoop::ExcludeSocketNotifiers, 50);
}
}
}
That will let it pass straight through the loop waiting for the cache to clear.
Perhaps there is some lock being held on the cache so that the second instance can never clear it properly.
If that is the case I will have to rethink/redesign the clearing of the cache code so that two different Sigil instances use separate caches. Perhaps by using uuid generation to make unique cache names.
If you get a free moment, please give that a try and let me know if that is the culprit.