Commit d6b75cfd authored by Marco Bubke's avatar Marco Bubke
Browse files

CppEditor: Slow down processor timer for clang



The timeout was too fast so we reparsed the document far to often.

Change-Id: Ib168d3e52b48dd2325accafb340872b55e71e42e
Reviewed-by: default avatarNikolai Kosjar <nikolai.kosjar@theqtcompany.com>
parent 09a107cc
......@@ -61,6 +61,8 @@ const char CPP_SNIPPETS_GROUP_ID[] = "C++";
const char CPP_PREPROCESSOR_PROJECT_PREFIX[] = "CppPreprocessorProject-";
const char CLANG_MODELMANAGERSUPPORT_ID[] = "ClangCodeMode.ClangCodeMode";
} // namespace Constants
} // namespace CppEditor
......
......@@ -63,7 +63,8 @@ CppTools::CppModelManager *mm()
namespace CppEditor {
namespace Internal {
enum { processDocumentIntervalInMs = 150 };
enum { processDocumentIntervalInMs = 150,
clangProcessDocumentIntervalInMs = 500 };
class CppEditorDocumentHandleImpl : public CppTools::CppEditorDocumentHandle
{
......@@ -113,10 +114,6 @@ CppEditorDocument::CppEditorDocument()
connect(this, &IDocument::filePathChanged,
this, &CppEditorDocument::onFilePathChanged);
m_processorTimer.setSingleShot(true);
m_processorTimer.setInterval(processDocumentIntervalInMs);
connect(&m_processorTimer, SIGNAL(timeout()), this, SLOT(processDocument()));
// See also onFilePathChanged() for more initialization
}
......@@ -185,6 +182,8 @@ void CppEditorDocument::onMimeTypeChanged()
m_isObjCEnabled = (mt == QLatin1String(CppTools::Constants::OBJECTIVE_C_SOURCE_MIMETYPE)
|| mt == QLatin1String(CppTools::Constants::OBJECTIVE_CPP_SOURCE_MIMETYPE));
m_completionAssistProvider = mm()->completionAssistProvider(mt);
initializeTimer();
}
void CppEditorDocument::onAboutToReload()
......@@ -225,7 +224,7 @@ void CppEditorDocument::onFilePathChanged(const Utils::FileName &oldPath,
void CppEditorDocument::scheduleProcessDocument()
{
m_processorRevision = document()->revision();
m_processorTimer.start(processDocumentIntervalInMs);
m_processorTimer.start();
}
void CppEditorDocument::processDocument()
......@@ -290,6 +289,21 @@ void CppEditorDocument::releaseResources()
m_processor.reset();
}
void CppEditorDocument::initializeTimer()
{
m_processorTimer.setSingleShot(true);
if (mm()->isManagedByModelManagerSupport(this, QLatin1String(Constants::CLANG_MODELMANAGERSUPPORT_ID)))
m_processorTimer.setInterval(clangProcessDocumentIntervalInMs);
else
m_processorTimer.setInterval(processDocumentIntervalInMs);
connect(&m_processorTimer,
&QTimer::timeout,
this,
&CppEditorDocument::processDocument,
Qt::UniqueConnection);
}
CppTools::BaseEditorDocumentProcessor *CppEditorDocument::processor()
{
if (!m_processor) {
......
......@@ -100,6 +100,8 @@ private:
void updatePreprocessorSettings();
void releaseResources();
void initializeTimer();
private:
bool m_fileIsBeingReloaded;
bool m_isObjCEnabled;
......
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