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

@@ -7,6 +7,7 @@
#include <qmljs/parser/qmljsastfwd_p.h>
#include <qmljs/qmljsdocument.h>
#include <qmljstools/qmljsrefactoringchanges.h>
#include <qmljstools/qmljssemanticinfo.h>
#include <QSharedPointer>
@@ -14,7 +15,6 @@ namespace QmlJSEditor {
namespace Internal { class QmlJSQuickFixAssistInterface; }
using QmlJSQuickFixInterface = QSharedPointer<const Internal::QmlJSQuickFixAssistInterface>;
using TextEditor::QuickFixOperation;
using TextEditor::QuickFixOperations;
using TextEditor::QuickFixInterface;
@@ -31,7 +31,8 @@ public:
\param interface The interface on which the operation is performed.
\param priority The priority for this operation.
*/
explicit QmlJSQuickFixOperation(const QmlJSQuickFixInterface &interface, int priority = -1);
explicit QmlJSQuickFixOperation(const Internal::QmlJSQuickFixAssistInterface *interface,
int priority = -1);
void perform() override;
@@ -41,13 +42,13 @@ protected:
virtual void performChanges(QmlJSTools::QmlJSRefactoringFilePtr currentFile,
const QmlJSTools::QmlJSRefactoringChanges &refactoring) = 0;
const Internal::QmlJSQuickFixAssistInterface *assistInterface() const;
const QmlJSTools::SemanticInfo &semanticInfo() const;
/// \returns The name of the file for for which this operation is invoked.
Utils::FilePath fileName() const;
private:
QmlJSQuickFixInterface m_interface;
const QmlJSTools::SemanticInfo m_semanticInfo;
};
TextEditor::QuickFixOperations findQmlJSQuickFixes(const TextEditor::AssistInterface *interface);