diff options
author | Jarek Kobus <jaroslaw.kobus@qt.io> | 2024-02-03 01:31:36 +0100 |
---|---|---|
committer | Jarek Kobus <jaroslaw.kobus@qt.io> | 2024-02-05 16:57:28 +0000 |
commit | 6744c1e69c770af3c233150156598f5f73b3d90c (patch) | |
tree | 28dafab986e99e68a01c6ef3f6eb47b51547a544 /src/plugins/cppeditor | |
parent | 2f81936218b0df190d7aaa5b5f50e3d325d3ab21 (diff) |
FunctionDeclDefLinkFinder: Replace QSharedPointer with std::shared_ptr
According to https://wiki.qt.io/Things_To_Look_Out_For_In_Reviews
QSharedPointer impl is poor and it's going to be removed from Qt 7.
Change-Id: I41b753f52d06bb35988d1a57478e06daaec04f31
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Christian Kandeler <christian.kandeler@qt.io>
Diffstat (limited to 'src/plugins/cppeditor')
-rw-r--r-- | src/plugins/cppeditor/cppeditorwidget.cpp | 8 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppeditorwidget.h | 4 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppfunctiondecldeflink.cpp | 12 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppfunctiondecldeflink.h | 6 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppfunctionparamrenaminghandler.cpp | 7 | ||||
-rw-r--r-- | src/plugins/cppeditor/cppquickfixes.cpp | 6 |
6 files changed, 21 insertions, 22 deletions
diff --git a/src/plugins/cppeditor/cppeditorwidget.cpp b/src/plugins/cppeditor/cppeditorwidget.cpp index 958a9089152..0eabd42e302 100644 --- a/src/plugins/cppeditor/cppeditorwidget.cpp +++ b/src/plugins/cppeditor/cppeditorwidget.cpp @@ -388,7 +388,7 @@ public: SemanticInfo m_lastSemanticInfo; FunctionDeclDefLinkFinder *m_declDefLinkFinder; - QSharedPointer<FunctionDeclDefLink> m_declDefLink; + std::shared_ptr<FunctionDeclDefLink> m_declDefLink; QAction *m_parseContextAction = nullptr; ParseContextWidget *m_parseContextWidget = nullptr; @@ -1299,7 +1299,7 @@ std::unique_ptr<AssistInterface> CppEditorWidget::createAssistInterface(AssistKi return TextEditorWidget::createAssistInterface(kind, reason); } -QSharedPointer<FunctionDeclDefLink> CppEditorWidget::declDefLink() const +std::shared_ptr<FunctionDeclDefLink> CppEditorWidget::declDefLink() const { return d->m_declDefLink; } @@ -1357,7 +1357,7 @@ void CppEditorWidget::updateFunctionDeclDefLinkNow() d->m_declDefLinkFinder->startFindLinkAt(textCursor(), semanticDoc, snapshot); } -void CppEditorWidget::onFunctionDeclDefLinkFound(QSharedPointer<FunctionDeclDefLink> link) +void CppEditorWidget::onFunctionDeclDefLinkFound(std::shared_ptr<FunctionDeclDefLink> link) { abortDeclDefLink(); d->m_declDefLink = link; @@ -1405,7 +1405,7 @@ void CppEditorWidget::abortDeclDefLink() } d->m_declDefLink->hideMarker(this); - d->m_declDefLink.clear(); + d->m_declDefLink.reset(); } void CppEditorWidget::showPreProcessorWidget() diff --git a/src/plugins/cppeditor/cppeditorwidget.h b/src/plugins/cppeditor/cppeditorwidget.h index e9259f8f4c7..3ec31ec64a4 100644 --- a/src/plugins/cppeditor/cppeditorwidget.h +++ b/src/plugins/cppeditor/cppeditorwidget.h @@ -43,7 +43,7 @@ public: bool isSemanticInfoValid() const; bool isRenaming() const; - QSharedPointer<Internal::FunctionDeclDefLink> declDefLink() const; + std::shared_ptr<Internal::FunctionDeclDefLink> declDefLink() const; void applyDeclDefLinkChanges(bool jumpToMatch); std::unique_ptr<TextEditor::AssistInterface> createAssistInterface( @@ -115,7 +115,7 @@ private: void updateFunctionDeclDefLink(); void updateFunctionDeclDefLinkNow(); void abortDeclDefLink(); - void onFunctionDeclDefLinkFound(QSharedPointer<Internal::FunctionDeclDefLink> link); + void onFunctionDeclDefLinkFound(std::shared_ptr<Internal::FunctionDeclDefLink> link); void onCodeWarningsUpdated(unsigned revision, const QList<QTextEdit::ExtraSelection> selections, diff --git a/src/plugins/cppeditor/cppfunctiondecldeflink.cpp b/src/plugins/cppeditor/cppfunctiondecldeflink.cpp index f6e83669144..87e520b2fd7 100644 --- a/src/plugins/cppeditor/cppfunctiondecldeflink.cpp +++ b/src/plugins/cppeditor/cppfunctiondecldeflink.cpp @@ -46,13 +46,13 @@ FunctionDeclDefLinkFinder::FunctionDeclDefLinkFinder(QObject *parent) void FunctionDeclDefLinkFinder::onFutureDone() { - QSharedPointer<FunctionDeclDefLink> link = m_watcher->result(); + std::shared_ptr<FunctionDeclDefLink> link = m_watcher->result(); m_watcher.reset(); if (link) { link->linkSelection = m_scannedSelection; link->nameSelection = m_nameSelection; if (m_nameSelection.selectedText() != link->nameInitial) - link.clear(); + link.reset(); } m_scannedSelection = QTextCursor(); m_nameSelection = QTextCursor(); @@ -129,9 +129,9 @@ static DeclaratorIdAST *getDeclaratorId(DeclaratorAST *declarator) return nullptr; } -static QSharedPointer<FunctionDeclDefLink> findLinkHelper(QSharedPointer<FunctionDeclDefLink> link, CppRefactoringChanges changes) +static std::shared_ptr<FunctionDeclDefLink> findLinkHelper(std::shared_ptr<FunctionDeclDefLink> link, CppRefactoringChanges changes) { - QSharedPointer<FunctionDeclDefLink> noResult; + std::shared_ptr<FunctionDeclDefLink> noResult; const Snapshot &snapshot = changes.snapshot(); // find the matching decl/def symbol @@ -225,7 +225,7 @@ void FunctionDeclDefLinkFinder::startFindLinkAt( m_nameSelection.setKeepPositionOnInsert(true); // set up a base result - QSharedPointer<FunctionDeclDefLink> result(new FunctionDeclDefLink); + std::shared_ptr<FunctionDeclDefLink> result(new FunctionDeclDefLink); result->nameInitial = m_nameSelection.selectedText(); result->sourceDocument = doc; result->sourceFunction = funcDecl->symbol; @@ -233,7 +233,7 @@ void FunctionDeclDefLinkFinder::startFindLinkAt( result->sourceFunctionDeclarator = funcDecl; // handle the rest in a thread - m_watcher.reset(new QFutureWatcher<QSharedPointer<FunctionDeclDefLink> >()); + m_watcher.reset(new QFutureWatcher<std::shared_ptr<FunctionDeclDefLink> >()); connect(m_watcher.data(), &QFutureWatcherBase::finished, this, &FunctionDeclDefLinkFinder::onFutureDone); m_watcher->setFuture(Utils::asyncRun(findLinkHelper, result, refactoringChanges)); } diff --git a/src/plugins/cppeditor/cppfunctiondecldeflink.h b/src/plugins/cppeditor/cppfunctiondecldeflink.h index 5621e355aaf..4ffce9bf915 100644 --- a/src/plugins/cppeditor/cppfunctiondecldeflink.h +++ b/src/plugins/cppeditor/cppfunctiondecldeflink.h @@ -3,12 +3,10 @@ #pragma once -#include "cppquickfix.h" #include "cpprefactoringchanges.h" #include <QString> #include <QCoreApplication> -#include <QSharedPointer> #include <QFutureWatcher> #include <QTextCursor> @@ -31,14 +29,14 @@ public: QTextCursor scannedSelection() const; signals: - void foundLink(QSharedPointer<FunctionDeclDefLink> link); + void foundLink(std::shared_ptr<FunctionDeclDefLink> link); private: void onFutureDone(); QTextCursor m_scannedSelection; QTextCursor m_nameSelection; - QScopedPointer<QFutureWatcher<QSharedPointer<FunctionDeclDefLink> > > m_watcher; + QScopedPointer<QFutureWatcher<std::shared_ptr<FunctionDeclDefLink>>> m_watcher; }; class FunctionDeclDefLink diff --git a/src/plugins/cppeditor/cppfunctionparamrenaminghandler.cpp b/src/plugins/cppeditor/cppfunctionparamrenaminghandler.cpp index 092e216b2d4..111f2659bad 100644 --- a/src/plugins/cppeditor/cppfunctionparamrenaminghandler.cpp +++ b/src/plugins/cppeditor/cppfunctionparamrenaminghandler.cpp @@ -6,6 +6,7 @@ #include "cppeditorwidget.h" #include "cpplocalrenaming.h" #include "cppfunctiondecldeflink.h" +#include "cppsemanticinfo.h" #include <cplusplus/AST.h> #include <cplusplus/ASTPath.h> @@ -17,7 +18,7 @@ using namespace CPlusPlus; namespace CppEditor::Internal { -using DeclDefLinkPtr = QSharedPointer<FunctionDeclDefLink>; +using DeclDefLinkPtr = std::shared_ptr<FunctionDeclDefLink>; class CppFunctionParamRenamingHandler::Private { @@ -54,7 +55,7 @@ CppFunctionParamRenamingHandler::Private::Private( void CppFunctionParamRenamingHandler::Private::handleRenamingStarted() { linkFinder.reset(); - link.clear(); + link.reset(); // Are we currently on the function signature? In this case, the normal decl/def link // mechanism kicks in and we don't have to do anything. @@ -78,7 +79,7 @@ void CppFunctionParamRenamingHandler::Private::handleRenamingFinished() { if (link) { link->apply(&editorWidget, false); - link.clear(); + link.reset(); } } diff --git a/src/plugins/cppeditor/cppquickfixes.cpp b/src/plugins/cppeditor/cppquickfixes.cpp index 47e7f90b05f..b4a844b396d 100644 --- a/src/plugins/cppeditor/cppquickfixes.cpp +++ b/src/plugins/cppeditor/cppquickfixes.cpp @@ -6412,7 +6412,7 @@ class ApplyDeclDefLinkOperation : public CppQuickFixOperation { public: explicit ApplyDeclDefLinkOperation(const CppQuickFixInterface &interface, - const QSharedPointer<FunctionDeclDefLink> &link) + const std::shared_ptr<FunctionDeclDefLink> &link) : CppQuickFixOperation(interface, 100) , m_link(link) {} @@ -6428,7 +6428,7 @@ protected: { /* never called since perform is overridden */ } private: - QSharedPointer<FunctionDeclDefLink> m_link; + std::shared_ptr<FunctionDeclDefLink> m_link; }; } // anonymous namespace @@ -6436,7 +6436,7 @@ private: void ApplyDeclDefLinkChanges::doMatch(const CppQuickFixInterface &interface, QuickFixOperations &result) { - QSharedPointer<FunctionDeclDefLink> link = interface.editor()->declDefLink(); + std::shared_ptr<FunctionDeclDefLink> link = interface.editor()->declDefLink(); if (!link || !link->isMarkerVisible()) return; |