QML: Fix crash when opening context menu

The AssistInterface changed to unique_ptr, but the internals of how the
QmlJSEditor looked for quick fixes still wrapped it into a
QSharedPointer, which then deleted the assist interface in addition to
the unique_ptr.

Amends 0e4b0a26d3

Fixes: QTCREATORBUG-28742
Change-Id: If685dbb2c49b09d529d0dcb3677dc90b03a039f0
Reviewed-by: Fabian Kosmale <fabian.kosmale@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
This commit is contained in:
Eike Ziller
2023-02-06 15:32:00 +01:00
committed by David Schulz
parent 8512aba9eb
commit 541aafecbb
7 changed files with 40 additions and 45 deletions

View File

@@ -2,8 +2,6 @@
// SPDX-License-Identifier: LicenseRef-Qt-Commercial OR GPL-3.0-only WITH Qt-GPL-exception-1.0
#include "qmljsquickfix.h"
#include "qmljscomponentfromobjectdef.h"
#include "qmljseditor.h"
#include "qmljsquickfixassist.h"
#include <extensionsystem/iplugin.h>
@@ -23,30 +21,29 @@ namespace QmlJSEditor {
using namespace Internal;
QmlJSQuickFixOperation::QmlJSQuickFixOperation(const QmlJSQuickFixInterface &interface,
QmlJSQuickFixOperation::QmlJSQuickFixOperation(const QmlJSQuickFixAssistInterface *interface,
int priority)
: QuickFixOperation(priority)
, m_interface(interface)
, m_semanticInfo(interface->semanticInfo())
{
}
void QmlJSQuickFixOperation::perform()
{
QmlJSRefactoringChanges refactoring(ModelManagerInterface::instance(),
m_interface->semanticInfo().snapshot);
QmlJSRefactoringChanges refactoring(ModelManagerInterface::instance(), semanticInfo().snapshot);
QmlJSRefactoringFilePtr current = refactoring.file(fileName());
performChanges(current, refactoring);
}
const QmlJSQuickFixAssistInterface *QmlJSQuickFixOperation::assistInterface() const
const QmlJSTools::SemanticInfo &QmlJSQuickFixOperation::semanticInfo() const
{
return m_interface.data();
return m_semanticInfo;
}
Utils::FilePath QmlJSQuickFixOperation::fileName() const
{
return m_interface->semanticInfo().document->fileName();
return semanticInfo().document->fileName();
}
} // namespace QmlJSEditor