forked from qt-creator/qt-creator
Git: InstantBlame: Fix multiple blame after file save
* Move document changed to slot and make sure it is a unique connection to prevent multiple slot calls * Still we get two changed signals after save, which caused two blame calls, avoid this with a marker Change-Id: I8f09ebc8c3cf9f9832fe2725c69acbea9a6b8c28 Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
committed by
André Hartmann
parent
e071a2d0ed
commit
7493b3a630
@@ -149,12 +149,10 @@ void InstantBlame::setup()
|
||||
}
|
||||
m_cursorPositionChangedTimer->start(500);
|
||||
});
|
||||
IDocument *document = editor->document();
|
||||
m_documentChangedConn = connect(document, &IDocument::changed, this, [this, document] {
|
||||
qCInfo(log) << "Document is changed:" << document;
|
||||
if (!document->isModified())
|
||||
force();
|
||||
});
|
||||
m_document = editor->document();
|
||||
m_documentChangedConn = connect(m_document, &IDocument::changed,
|
||||
this, &InstantBlame::slotDocumentChanged,
|
||||
Qt::UniqueConnection);
|
||||
|
||||
force();
|
||||
};
|
||||
@@ -353,4 +351,19 @@ bool InstantBlame::refreshWorkingDirectory(const FilePath &workingDirectory)
|
||||
return true;
|
||||
}
|
||||
|
||||
void InstantBlame::slotDocumentChanged()
|
||||
{
|
||||
if (m_document == nullptr) {
|
||||
qCWarning(log) << "Document is invalid, disconnecting.";
|
||||
disconnect(m_documentChangedConn);
|
||||
return;
|
||||
}
|
||||
|
||||
const bool modified = m_document->isModified();
|
||||
qCDebug(log) << "Document is changed, modified:" << modified;
|
||||
if (m_modified && !modified)
|
||||
force();
|
||||
m_modified = modified;
|
||||
}
|
||||
|
||||
} // Git::Internal
|
||||
|
||||
Reference in New Issue
Block a user