forked from qt-creator/qt-creator
Clang: Fix possible future watcher issues in local renaming
Use the same code pattern as in asynchronous branch of CppUseSelectionsUpdater::update. Change-Id: I7c06b883a5abe1324cb63fa410247ef7f50321ae Reviewed-by: Nikolai Kosjar <nikolai.kosjar@qt.io>
This commit is contained in:
@@ -51,10 +51,14 @@ void RefactoringEngine::startLocalRenaming(const CppTools::CursorInEditor &data,
|
||||
if (cursorFuture.isCanceled())
|
||||
return defaultCallback();
|
||||
|
||||
QObject::connect(&m_watcher, &FutureCursorWatcher::finished, [=]() {
|
||||
if (m_watcher.isCanceled())
|
||||
if (m_watcher)
|
||||
m_watcher->cancel();
|
||||
|
||||
m_watcher.reset(new FutureCursorWatcher());
|
||||
QObject::connect(m_watcher.get(), &FutureCursorWatcher::finished, [=]() {
|
||||
if (m_watcher->isCanceled())
|
||||
return defaultCallback();
|
||||
const CppTools::CursorInfo info = m_watcher.result();
|
||||
const CppTools::CursorInfo info = m_watcher->result();
|
||||
if (info.useRanges.empty())
|
||||
return defaultCallback();
|
||||
|
||||
@@ -72,7 +76,7 @@ void RefactoringEngine::startLocalRenaming(const CppTools::CursorInEditor &data,
|
||||
renameSymbolsCallback(symbolName, container, data.cursor().document()->revision());
|
||||
});
|
||||
|
||||
m_watcher.setFuture(cursorFuture);
|
||||
m_watcher->setFuture(cursorFuture);
|
||||
}
|
||||
|
||||
}
|
||||
|
@@ -55,7 +55,7 @@ public:
|
||||
|
||||
private:
|
||||
using FutureCursorWatcher = QFutureWatcher<CppTools::CursorInfo>;
|
||||
FutureCursorWatcher m_watcher;
|
||||
std::unique_ptr<FutureCursorWatcher> m_watcher;
|
||||
};
|
||||
|
||||
} // namespace ClangRefactoring
|
||||
|
Reference in New Issue
Block a user