QmlJSEditor: Fix crash when triggering context menu

Regression introduced with 3da9c89981.

Change-Id: Ia0ede1b46b7bc8cbce8b55335b3a548e7f8d384d
Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
Christian Stenger
2018-02-21 11:47:01 +01:00
parent 84e17dd0f8
commit e7663d0cce
4 changed files with 12 additions and 4 deletions

View File

@@ -35,10 +35,10 @@
#include "qmljshoverhandler.h"
#include "qmljsquickfixassist.h"
#include "qmloutlinemodel.h"
#include "quicktoolbar.h"
#include <qmljs/qmljsbind.h>
#include <qmljs/qmljsevaluate.h>
#include <qmljs/qmljsicontextpane.h>
#include <qmljs/qmljsmodelmanagerinterface.h>
#include <qmljs/qmljsutils.h>
@@ -129,7 +129,7 @@ void QmlJSEditorWidget::finalizeInitialization()
textDocument()->setCodec(QTextCodec::codecForName("UTF-8")); // qml files are defined to be utf-8
m_modelManager = ModelManagerInterface::instance();
m_contextPane = ExtensionSystem::PluginManager::getObject<IContextPane>();
m_contextPane = QmlJSEditorPlugin::quickToolBar();
m_modelManager->activateScan();

View File

@@ -43,13 +43,13 @@ QT_END_NAMESPACE
namespace QmlJS {
class ModelManagerInterface;
class IContextPane;
namespace AST { class UiObjectMember; }
}
namespace QmlJSEditor {
class QmlJSEditorDocument;
class QuickToolBar;
class FindReferences;
namespace Internal {
@@ -124,7 +124,7 @@ private:
QModelIndex m_outlineModelIndex;
QmlJS::ModelManagerInterface *m_modelManager = nullptr;
QmlJS::IContextPane *m_contextPane = nullptr;
QuickToolBar *m_contextPane = nullptr;
int m_oldCursorPosition = -1;
FindReferences *m_findReferences;

View File

@@ -238,6 +238,12 @@ Utils::JsonSchemaManager *QmlJSEditorPlugin::jsonManager()
return &m_instance->d->m_jsonManager;
}
QuickToolBar *QmlJSEditorPlugin::quickToolBar()
{
QTC_ASSERT(m_instance && m_instance->d, return new QuickToolBar());
return &m_instance->d->m_quickToolBar;
}
void QmlJSEditorPluginPrivate::findUsages()
{
if (QmlJSEditorWidget *editor = qobject_cast<QmlJSEditorWidget*>(EditorManager::currentEditor()->widget()))

View File

@@ -30,6 +30,7 @@
namespace Utils { class JsonSchemaManager; }
namespace QmlJSEditor {
class QuickToolBar;
namespace Internal {
class QmlJSQuickFixAssistProvider;
@@ -45,6 +46,7 @@ public:
static QmlJSQuickFixAssistProvider *quickFixAssistProvider();
static Utils::JsonSchemaManager *jsonManager();
static QuickToolBar *quickToolBar();
private:
bool initialize(const QStringList &arguments, QString *errorMessage) final;