forked from qt-creator/qt-creator
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>
This commit is contained in:
@@ -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()
|
||||
|
@@ -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,
|
||||
|
@@ -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));
|
||||
}
|
||||
|
@@ -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
|
||||
|
@@ -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();
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -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;
|
||||
|
||||
|
Reference in New Issue
Block a user