Commit 3a8564c1 authored by Eike Ziller's avatar Eike Ziller
Browse files

Fix reloading documents when they are changed fast, multiple times.



This can for example happen when doing interactive git rebases.

* When a file was changed after we reloaded it, but before we removed
+readded the watcher, we wouldn't get a notification for these changes.

* When we got a file changed notification while we were in checkForReload
(because of event processing of the dialog, or file loading), the
notification was dropped and only processes when a check was triggered
again (e.g. at window activation, or when some (other) file changed)

Change-Id: Iab1861a8f05c739a3405bc1afe90ae6f2145057b
Task-number: QTCREATORBUG-9745
Reviewed-by: default avatarDaniel Teske <daniel.teske@theqtcompany.com>
Reviewed-by: default avatarOrgad Shaneh <orgads@gmail.com>
parent 7cb9b0cf
......@@ -908,14 +908,16 @@ void DocumentManager::checkForReload()
if (!QApplication::activeWindow())
return;
if (QApplication::activeModalWidget()) { // a modal dialog, recheck later
if (QApplication::activeModalWidget() || d->m_blockActivated) {
// We do not want to prompt for modified file if we currently have some modal dialog open.
// If d->m_blockActivated is true, then it means that the event processing of either the
// file modified dialog, or of loading large files, has delivered a file change event from
// a watcher *and* the timer triggered. We may never end up here in a nested way, so
// recheck later.
QTimer::singleShot(200, this, SLOT(checkForReload()));
return;
}
if (d->m_blockActivated)
return;
d->m_blockActivated = true;
IDocument::ReloadSetting defaultBehavior = EditorManagerPrivate::reloadSetting();
......@@ -1009,6 +1011,14 @@ void DocumentManager::checkForReload()
// handle it!
d->m_blockedIDocument = document;
// Update file info, also handling if e.g. link target has changed.
// We need to do that before the file is reloaded, because removing the watcher will
// loose any pending change events. Loosing change events *before* the file is reloaded
// doesn't matter, because in that case we then reload the new version of the file already
// anyhow.
removeFileInfo(document);
addFileInfo(document);
bool success = true;
QString errorString;
// we've got some modification
......@@ -1110,9 +1120,6 @@ void DocumentManager::checkForReload()
errorStrings << errorString;
}
// update file info, also handling if e.g. link target has changed
removeFileInfo(document);
addFileInfo(document);
d->m_blockedIDocument = 0;
}
if (!errorStrings.isEmpty())
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment