diff options
Diffstat (limited to 'src/plugins/cppeditor')
-rw-r--r-- | src/plugins/cppeditor/cppeditor.cpp | 29 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppeditordocument.cpp | 8 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppquickfixes.cpp | 3 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppuseselectionsupdater.cpp | 6 |
4 files changed, 35 insertions, 11 deletions
diff --git a/src/plugins/cppeditor/cppeditor.cpp b/src/plugins/cppeditor/cppeditor.cpp index 677cd1ebc3..65d0c42abf 100644 --- a/src/plugins/cppeditor/cppeditor.cpp +++ b/src/plugins/cppeditor/cppeditor.cpp @@ -245,13 +245,19 @@ void CppEditorWidget::finalizeInitialization() }); // Toolbar: '#' Button - d->m_preprocessorButton = new QToolButton(this); - d->m_preprocessorButton->setText(QLatin1String("#")); - Command *cmd = ActionManager::command(Constants::OPEN_PREPROCESSOR_DIALOG); - connect(cmd, &Command::keySequenceChanged, this, &CppEditorWidget::updatePreprocessorButtonTooltip); - updatePreprocessorButtonTooltip(); - connect(d->m_preprocessorButton, &QAbstractButton::clicked, this, &CppEditorWidget::showPreProcessorWidget); - insertExtraToolBarWidget(TextEditorWidget::Left, d->m_preprocessorButton); + // TODO: Make "Additional Preprocessor Directives" also useful with Clang Code Model. + if (!d->m_modelManager->isClangCodeModelActive()) { + d->m_preprocessorButton = new QToolButton(this); + d->m_preprocessorButton->setText(QLatin1String("#")); + Command *cmd = ActionManager::command(Constants::OPEN_PREPROCESSOR_DIALOG); + connect(cmd, &Command::keySequenceChanged, + this, &CppEditorWidget::updatePreprocessorButtonTooltip); + updatePreprocessorButtonTooltip(); + connect(d->m_preprocessorButton, &QAbstractButton::clicked, + this, &CppEditorWidget::showPreProcessorWidget); + + insertExtraToolBarWidget(TextEditorWidget::Left, d->m_preprocessorButton); + } // Toolbar: Actions to show minimized info bars d->m_showInfoBarActions = MinimizableInfoBars::createShowInfoBarActions([this](QWidget *w) { @@ -429,13 +435,16 @@ bool CppEditorWidget::selectBlockDown() void CppEditorWidget::updateWidgetHighlighting(QWidget *widget, bool highlight) { + if (!widget) + return; + widget->setProperty("highlightWidget", highlight); widget->update(); } bool CppEditorWidget::isWidgetHighlighted(QWidget *widget) { - return widget->property("highlightWidget").toBool(); + return widget ? widget->property("highlightWidget").toBool() : false; } void CppEditorWidget::renameSymbolUnderCursor() @@ -586,7 +595,9 @@ void CppEditorWidget::renameSymbolUnderCursorClang() void CppEditorWidget::updatePreprocessorButtonTooltip() { - QTC_ASSERT(d->m_preprocessorButton, return); + if (!d->m_preprocessorButton) + return; + Command *cmd = ActionManager::command(Constants::OPEN_PREPROCESSOR_DIALOG); QTC_ASSERT(cmd, return); d->m_preprocessorButton->setToolTip(cmd->action()->toolTip()); diff --git a/src/plugins/cppeditor/cppeditordocument.cpp b/src/plugins/cppeditor/cppeditordocument.cpp index c5a9d40e2e..d31a4eb899 100644 --- a/src/plugins/cppeditor/cppeditordocument.cpp +++ b/src/plugins/cppeditor/cppeditordocument.cpp @@ -201,12 +201,17 @@ void CppEditorDocument::onAboutToReload() { QTC_CHECK(!m_fileIsBeingReloaded); m_fileIsBeingReloaded = true; + + processor()->invalidateDiagnostics(); } void CppEditorDocument::onReloadFinished() { QTC_CHECK(m_fileIsBeingReloaded); m_fileIsBeingReloaded = false; + + m_processorRevision = document()->revision(); + processDocument(); } void CppEditorDocument::reparseWithPreferredParseContext(const QString &parseContextId) @@ -250,6 +255,9 @@ void CppEditorDocument::onFilePathChanged(const Utils::FileName &oldPath, void CppEditorDocument::scheduleProcessDocument() { + if (m_fileIsBeingReloaded) + return; + m_processorRevision = document()->revision(); m_processorTimer.start(); processor()->editorDocumentTimerRestarted(); diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index 67d360c3bb..640fa794ef 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -56,6 +56,7 @@ #include <utils/fancylineedit.h> #include <utils/qtcassert.h> +#include <utils/qtcfallthrough.h> #include <QApplication> #include <QComboBox> @@ -4119,7 +4120,7 @@ public: break; case FromReference: removeReferenceOperator(changes); - // fallthrough intended + Q_FALLTHROUGH(); case FromVariable: convertToPointer(changes); break; diff --git a/src/plugins/cppeditor/cppuseselectionsupdater.cpp b/src/plugins/cppeditor/cppuseselectionsupdater.cpp index 5e03ebbe2d..81e1436ccd 100644 --- a/src/plugins/cppeditor/cppuseselectionsupdater.cpp +++ b/src/plugins/cppeditor/cppuseselectionsupdater.cpp @@ -98,8 +98,12 @@ void CppUseSelectionsUpdater::update(CallType callType) // QFuture::waitForFinished seems to block completely, not even // allowing to process events from QLocalSocket. - while (!future.isFinished()) + while (!future.isFinished()) { + if (future.isCanceled()) + return; + QCoreApplication::processEvents(QEventLoop::ExcludeUserInputEvents); + } processResults(future.result()); } |