forked from qt-creator/qt-creator
CppEditor: Fix race condition for highlighting of local usages
Starting a renaming action involves looking up local usages. In this case, a different code path than normal updates the editor's extra selections, in order to make sure that the occurrence to be edited is rendered in a special way. We must therefore prevent the normal handler from taking action, as it would overwrite abovementioned special selection. Change-Id: Ia811b49b3023a0a366a43a69cc01e6b2b370acb5 Reviewed-by: David Schulz <david.schulz@qt.io>
This commit is contained in:
@@ -805,6 +805,11 @@ bool CppEditorWidget::isSemanticInfoValid() const
|
||||
return isSemanticInfoValidExceptLocalUses() && d->m_lastSemanticInfo.localUsesUpdated;
|
||||
}
|
||||
|
||||
bool CppEditorWidget::isRenaming() const
|
||||
{
|
||||
return d->m_localRenaming.isActive();
|
||||
}
|
||||
|
||||
SemanticInfo CppEditorWidget::semanticInfo() const
|
||||
{
|
||||
return d->m_lastSemanticInfo;
|
||||
|
||||
@@ -60,6 +60,7 @@ public:
|
||||
|
||||
bool isSemanticInfoValidExceptLocalUses() const;
|
||||
bool isSemanticInfoValid() const;
|
||||
bool isRenaming() const;
|
||||
|
||||
QSharedPointer<FunctionDeclDefLink> declDefLink() const;
|
||||
void applyDeclDefLinkChanges(bool jumpToMatch);
|
||||
|
||||
@@ -41,7 +41,7 @@ enum { updateUseSelectionsInternalInMs = 500 };
|
||||
namespace CppEditor {
|
||||
namespace Internal {
|
||||
|
||||
CppUseSelectionsUpdater::CppUseSelectionsUpdater(TextEditor::TextEditorWidget *editorWidget)
|
||||
CppUseSelectionsUpdater::CppUseSelectionsUpdater(CppEditorWidget *editorWidget)
|
||||
: m_editorWidget(editorWidget)
|
||||
{
|
||||
m_timer.setSingleShot(true);
|
||||
@@ -157,6 +157,10 @@ void CppUseSelectionsUpdater::onFindUsesFinished()
|
||||
emit finished(CppTools::SemanticInfo::LocalUseMap(), false);
|
||||
return;
|
||||
}
|
||||
if (m_editorWidget->isRenaming()) {
|
||||
emit finished({}, false);
|
||||
return;
|
||||
}
|
||||
|
||||
processResults(m_runnerWatcher->result());
|
||||
|
||||
|
||||
@@ -32,18 +32,18 @@
|
||||
#include <QTextEdit>
|
||||
#include <QTimer>
|
||||
|
||||
namespace TextEditor { class TextEditorWidget; }
|
||||
|
||||
namespace CppEditor {
|
||||
namespace Internal {
|
||||
|
||||
class CppEditorWidget;
|
||||
|
||||
class CppUseSelectionsUpdater : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_DISABLE_COPY(CppUseSelectionsUpdater)
|
||||
|
||||
public:
|
||||
explicit CppUseSelectionsUpdater(TextEditor::TextEditorWidget *editorWidget);
|
||||
explicit CppUseSelectionsUpdater(CppEditorWidget *editorWidget);
|
||||
~CppUseSelectionsUpdater() override;
|
||||
|
||||
void scheduleUpdate();
|
||||
@@ -73,7 +73,7 @@ private:
|
||||
void updateUnusedSelections(const CursorInfo::Ranges &selections);
|
||||
|
||||
private:
|
||||
TextEditor::TextEditorWidget *m_editorWidget;
|
||||
CppEditorWidget * const m_editorWidget;
|
||||
|
||||
QTimer m_timer;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user