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);
|
m_cursorPositionChangedTimer->start(500);
|
||||||
});
|
});
|
||||||
IDocument *document = editor->document();
|
m_document = editor->document();
|
||||||
m_documentChangedConn = connect(document, &IDocument::changed, this, [this, document] {
|
m_documentChangedConn = connect(m_document, &IDocument::changed,
|
||||||
qCInfo(log) << "Document is changed:" << document;
|
this, &InstantBlame::slotDocumentChanged,
|
||||||
if (!document->isModified())
|
Qt::UniqueConnection);
|
||||||
force();
|
|
||||||
});
|
|
||||||
|
|
||||||
force();
|
force();
|
||||||
};
|
};
|
||||||
@@ -353,4 +351,19 @@ bool InstantBlame::refreshWorkingDirectory(const FilePath &workingDirectory)
|
|||||||
return true;
|
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
|
} // Git::Internal
|
||||||
|
@@ -54,11 +54,14 @@ public:
|
|||||||
|
|
||||||
private:
|
private:
|
||||||
bool refreshWorkingDirectory(const Utils::FilePath &workingDirectory);
|
bool refreshWorkingDirectory(const Utils::FilePath &workingDirectory);
|
||||||
|
void slotDocumentChanged();
|
||||||
|
|
||||||
Utils::FilePath m_workingDirectory;
|
Utils::FilePath m_workingDirectory;
|
||||||
QTextCodec *m_codec = nullptr;
|
QTextCodec *m_codec = nullptr;
|
||||||
Author m_author;
|
Author m_author;
|
||||||
int m_lastVisitedEditorLine = -1;
|
int m_lastVisitedEditorLine = -1;
|
||||||
|
Core::IDocument *m_document = nullptr;
|
||||||
|
bool m_modified = false;
|
||||||
QTimer *m_cursorPositionChangedTimer = nullptr;
|
QTimer *m_cursorPositionChangedTimer = nullptr;
|
||||||
std::unique_ptr<BlameMark> m_blameMark;
|
std::unique_ptr<BlameMark> m_blameMark;
|
||||||
QMetaObject::Connection m_blameCursorPosConn;
|
QMetaObject::Connection m_blameCursorPosConn;
|
||||||
|
Reference in New Issue
Block a user