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