From 3da9c8998139308270eec27eb9b5dddd74090bf5 Mon Sep 17 00:00:00 2001 From: hjk Date: Thu, 15 Feb 2018 09:50:02 +0100 Subject: [PATCH] QmlJSEditorPlugin: Refactor This follows the recently introduced pattern for plugin setup - Pimpl QmlJSEditorPlugin - remove unneeded uses of global object pool - apply "static pattern" - simplify some constructors of data members in some cases - use in-class initialization in some case Change-Id: I95b42d0885f4a8d6c9bfe1e4c004d3ace0a3eba5 Reviewed-by: Marco Benelli Reviewed-by: David Schulz --- src/plugins/qmljseditor/qmljseditor.cpp | 2 +- .../qmljseditor/qmljseditordocument.cpp | 2 +- src/plugins/qmljseditor/qmljseditorplugin.cpp | 184 ++++++++++-------- src/plugins/qmljseditor/qmljseditorplugin.h | 60 +----- .../qmljseditor/qmljsquickfixassist.cpp | 6 - src/plugins/qmljseditor/qmljsquickfixassist.h | 4 +- .../qmljseditor/qmljssemanticinfoupdater.cpp | 3 +- src/plugins/qmljseditor/qmltaskmanager.cpp | 4 +- src/plugins/qmljseditor/qmltaskmanager.h | 4 +- src/plugins/qmljseditor/quicktoolbar.cpp | 6 +- src/plugins/qmljseditor/quicktoolbar.h | 8 +- 11 files changed, 120 insertions(+), 163 deletions(-) diff --git a/src/plugins/qmljseditor/qmljseditor.cpp b/src/plugins/qmljseditor/qmljseditor.cpp index 946edbd078b..ef99d338882 100644 --- a/src/plugins/qmljseditor/qmljseditor.cpp +++ b/src/plugins/qmljseditor/qmljseditor.cpp @@ -829,7 +829,7 @@ void QmlJSEditorWidget::contextMenuEvent(QContextMenuEvent *e) AssistInterface *interface = createAssistInterface(QuickFix, ExplicitlyInvoked); if (interface) { QScopedPointer processor( - QmlJSEditorPlugin::instance()->quickFixAssistProvider()->createProcessor()); + QmlJSEditorPlugin::quickFixAssistProvider()->createProcessor()); QScopedPointer proposal(processor->perform(interface)); if (!proposal.isNull()) { GenericProposalModel *model = static_cast(proposal->model()); diff --git a/src/plugins/qmljseditor/qmljseditordocument.cpp b/src/plugins/qmljseditor/qmljseditordocument.cpp index 66fa6da393e..f0b846d56f1 100644 --- a/src/plugins/qmljseditor/qmljseditordocument.cpp +++ b/src/plugins/qmljseditor/qmljseditordocument.cpp @@ -685,7 +685,7 @@ Internal::QmlOutlineModel *QmlJSEditorDocument::outlineModel() const TextEditor::IAssistProvider *QmlJSEditorDocument::quickFixAssistProvider() const { - return Internal::QmlJSEditorPlugin::instance()->quickFixAssistProvider(); + return Internal::QmlJSEditorPlugin::quickFixAssistProvider(); } void QmlJSEditorDocument::setDiagnosticRanges(const QVector &ranges) diff --git a/src/plugins/qmljseditor/qmljseditorplugin.cpp b/src/plugins/qmljseditor/qmljseditorplugin.cpp index 405dfac3e76..4c5b6172a70 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.cpp +++ b/src/plugins/qmljseditor/qmljseditorplugin.cpp @@ -58,12 +58,7 @@ #include #include -#include -#include -#include -#include #include -#include #include #include @@ -71,57 +66,88 @@ using namespace QmlJSEditor::Constants; using namespace ProjectExplorer; using namespace Core; -enum { - QUICKFIX_INTERVAL = 20 +namespace QmlJSEditor { +namespace Internal { + +class QmlJSEditorPluginPrivate : public QObject +{ +public: + QmlJSEditorPluginPrivate(); + + void currentEditorChanged(IEditor *editor); + void runSemanticScan(); + void checkCurrentEditorSemanticInfoUpToDate(); + void autoFormatOnSave(IDocument *document); + + Command *addToolAction(QAction *a, Context &context, Id id, + ActionContainer *c1, const QString &keySequence); + + void findUsages(); + void renameUsages(); + void reformatFile(); + void showContextPane(); + + QmlJSQuickFixAssistProvider m_quickFixAssistProvider; + QmlTaskManager m_qmlTaskManager; + + QAction *m_reformatFileAction = nullptr; + + QPointer m_currentDocument; + + Utils::JsonSchemaManager m_jsonManager{{ICore::userResourcePath() + "/json/", + ICore::resourcePath() + "/json/"}}; + QmlJSEditorFactory m_qmlJSEditorFactory; + QmlJSOutlineWidgetFactory m_qmlJSOutlineWidgetFactory; + QuickToolBar m_quickToolBar; + QmlJsEditingSettingsPage m_qmJSEditingSettingsPage; }; -namespace QmlJSEditor { -using namespace Internal; +static QmlJSEditorPlugin *m_instance = nullptr; -QmlJSEditorPlugin *QmlJSEditorPlugin::m_instance = 0; - -QmlJSEditorPlugin::QmlJSEditorPlugin() : - m_modelManager(0), - m_quickFixAssistProvider(0), - m_reformatFileAction(0), - m_currentDocument(0), - m_jsonManager(new Utils::JsonSchemaManager( - QStringList() << ICore::userResourcePath() + QLatin1String("/json/") - << ICore::resourcePath() + QLatin1String("/json/"))) +QmlJSEditorPlugin::QmlJSEditorPlugin() { m_instance = this; } QmlJSEditorPlugin::~QmlJSEditorPlugin() { - m_instance = 0; + delete d; + d = nullptr; + m_instance = nullptr; } -bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *errorMessage) +bool QmlJSEditorPlugin::initialize(const QStringList &arguments, QString *errorMessage) +{ + Q_UNUSED(arguments); + Q_UNUSED(errorMessage); + + d = new QmlJSEditorPluginPrivate; + + return true; +} + +QmlJSEditorPluginPrivate::QmlJSEditorPluginPrivate() { - m_modelManager = QmlJS::ModelManagerInterface::instance(); TextEditor::SnippetProvider::registerGroup(Constants::QML_SNIPPETS_GROUP_ID, - tr("QML", "SnippetProvider"), + QmlJSEditorPlugin::tr("QML", "SnippetProvider"), &QmlJSEditorFactory::decorateEditor); + QmlJS::ModelManagerInterface *modelManager = QmlJS::ModelManagerInterface::instance(); + // QML task updating manager - m_qmlTaskManager = new QmlTaskManager; - addAutoReleasedObject(m_qmlTaskManager); - connect(m_modelManager, &QmlJS::ModelManagerInterface::documentChangedOnDisk, - m_qmlTaskManager, &QmlTaskManager::updateMessages); + connect(modelManager, &QmlJS::ModelManagerInterface::documentChangedOnDisk, + &m_qmlTaskManager, &QmlTaskManager::updateMessages); // recompute messages when information about libraries changes - connect(m_modelManager, &QmlJS::ModelManagerInterface::libraryInfoUpdated, - m_qmlTaskManager, &QmlTaskManager::updateMessages); + connect(modelManager, &QmlJS::ModelManagerInterface::libraryInfoUpdated, + &m_qmlTaskManager, &QmlTaskManager::updateMessages); // recompute messages when project data changes (files added or removed) - connect(m_modelManager, &QmlJS::ModelManagerInterface::projectInfoUpdated, - m_qmlTaskManager, &QmlTaskManager::updateMessages); - connect(m_modelManager, &QmlJS::ModelManagerInterface::aboutToRemoveFiles, - m_qmlTaskManager, &QmlTaskManager::documentsRemoved); + connect(modelManager, &QmlJS::ModelManagerInterface::projectInfoUpdated, + &m_qmlTaskManager, &QmlTaskManager::updateMessages); + connect(modelManager, &QmlJS::ModelManagerInterface::aboutToRemoveFiles, + &m_qmlTaskManager, &QmlTaskManager::documentsRemoved); Context context(Constants::C_QMLJSEDITOR_ID); - addAutoReleasedObject(new QmlJSEditorFactory); - ActionContainer *contextMenu = ActionManager::createMenu(Constants::M_CONTEXT); ActionContainer *qmlToolsMenu = ActionManager::actionContainer(Id(QmlJSTools::Constants::M_TOOLS_QMLJS)); @@ -132,32 +158,32 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e contextMenu->addAction(cmd); qmlToolsMenu->addAction(cmd); - QAction *findUsagesAction = new QAction(tr("Find Usages"), this); + QAction *findUsagesAction = new QAction(QmlJSEditorPlugin::tr("Find Usages"), this); cmd = ActionManager::registerAction(findUsagesAction, Constants::FIND_USAGES, context); - cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+U"))); - connect(findUsagesAction, &QAction::triggered, this, &QmlJSEditorPlugin::findUsages); + cmd->setDefaultKeySequence(QKeySequence(QmlJSEditorPlugin::tr("Ctrl+Shift+U"))); + connect(findUsagesAction, &QAction::triggered, this, &QmlJSEditorPluginPrivate::findUsages); contextMenu->addAction(cmd); qmlToolsMenu->addAction(cmd); - QAction *renameUsagesAction = new QAction(tr("Rename Symbol Under Cursor"), this); + QAction *renameUsagesAction = new QAction(QmlJSEditorPlugin::tr("Rename Symbol Under Cursor"), this); cmd = ActionManager::registerAction(renameUsagesAction, Constants::RENAME_USAGES, context); - cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+R"))); - connect(renameUsagesAction, &QAction::triggered, this, &QmlJSEditorPlugin::renameUsages); + cmd->setDefaultKeySequence(QKeySequence(QmlJSEditorPlugin::tr("Ctrl+Shift+R"))); + connect(renameUsagesAction, &QAction::triggered, this, &QmlJSEditorPluginPrivate::renameUsages); contextMenu->addAction(cmd); qmlToolsMenu->addAction(cmd); - QAction *semanticScan = new QAction(tr("Run Checks"), this); + QAction *semanticScan = new QAction(QmlJSEditorPlugin::tr("Run Checks"), this); cmd = ActionManager::registerAction(semanticScan, Id(Constants::RUN_SEMANTIC_SCAN)); - cmd->setDefaultKeySequence(QKeySequence(tr("Ctrl+Shift+C"))); - connect(semanticScan, &QAction::triggered, this, &QmlJSEditorPlugin::runSemanticScan); + cmd->setDefaultKeySequence(QKeySequence(QmlJSEditorPlugin::tr("Ctrl+Shift+C"))); + connect(semanticScan, &QAction::triggered, this, &QmlJSEditorPluginPrivate::runSemanticScan); qmlToolsMenu->addAction(cmd); - m_reformatFileAction = new QAction(tr("Reformat File"), this); + m_reformatFileAction = new QAction(QmlJSEditorPlugin::tr("Reformat File"), this); cmd = ActionManager::registerAction(m_reformatFileAction, Id(Constants::REFORMAT_FILE), context); - connect(m_reformatFileAction, &QAction::triggered, this, &QmlJSEditorPlugin::reformatFile); + connect(m_reformatFileAction, &QAction::triggered, this, &QmlJSEditorPluginPrivate::reformatFile); qmlToolsMenu->addAction(cmd); - QAction *inspectElementAction = new QAction(tr("Inspect API for Element Under Cursor"), this); + QAction *inspectElementAction = new QAction(QmlJSEditorPlugin::tr("Inspect API for Element Under Cursor"), this); cmd = ActionManager::registerAction(inspectElementAction, Id(Constants::INSPECT_ELEMENT_UNDER_CURSOR), context); connect(inspectElementAction, &QAction::triggered, [] { @@ -166,11 +192,11 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e }); qmlToolsMenu->addAction(cmd); - QAction *showQuickToolbar = new QAction(tr("Show Qt Quick Toolbar"), this); + QAction *showQuickToolbar = new QAction(QmlJSEditorPlugin::tr("Show Qt Quick Toolbar"), this); cmd = ActionManager::registerAction(showQuickToolbar, Constants::SHOW_QT_QUICK_HELPER, context); cmd->setDefaultKeySequence(useMacShortcuts ? QKeySequence(Qt::META + Qt::ALT + Qt::Key_Space) : QKeySequence(Qt::CTRL + Qt::ALT + Qt::Key_Space)); - connect(showQuickToolbar, &QAction::triggered, this, &QmlJSEditorPlugin::showContextPane); + connect(showQuickToolbar, &QAction::triggered, this, &QmlJSEditorPluginPrivate::showContextPane); contextMenu->addAction(cmd); qmlToolsMenu->addAction(cmd); @@ -185,24 +211,13 @@ bool QmlJSEditorPlugin::initialize(const QStringList & /*arguments*/, QString *e cmd = ActionManager::command(TextEditor::Constants::UN_COMMENT_SELECTION); contextMenu->addAction(cmd); - m_quickFixAssistProvider = new QmlJSQuickFixAssistProvider(this); - - errorMessage->clear(); - FileIconProvider::registerIconOverlayForSuffix(ProjectExplorer::Constants::FILEOVERLAY_QML, "qml"); - addAutoReleasedObject(new QmlJSOutlineWidgetFactory); - - addAutoReleasedObject(new QuickToolBar); - addAutoReleasedObject(new QmlJsEditingSettingsPage); - connect(EditorManager::instance(), &EditorManager::currentEditorChanged, - this, &QmlJSEditorPlugin::currentEditorChanged); + this, &QmlJSEditorPluginPrivate::currentEditorChanged); - connect(EditorManager::instance(), &Core::EditorManager::aboutToSave, - this, &QmlJSEditorPlugin::autoFormatOnSave); - - return true; + connect(EditorManager::instance(), &EditorManager::aboutToSave, + this, &QmlJSEditorPluginPrivate::autoFormatOnSave); } void QmlJSEditorPlugin::extensionsInitialized() @@ -218,24 +233,24 @@ ExtensionSystem::IPlugin::ShutdownFlag QmlJSEditorPlugin::aboutToShutdown() return IPlugin::aboutToShutdown(); } -Utils::JsonSchemaManager *QmlJSEditorPlugin::jsonManager() const +Utils::JsonSchemaManager *QmlJSEditorPlugin::jsonManager() { - return m_jsonManager.data(); + return &m_instance->d->m_jsonManager; } -void QmlJSEditorPlugin::findUsages() +void QmlJSEditorPluginPrivate::findUsages() { if (QmlJSEditorWidget *editor = qobject_cast(EditorManager::currentEditor()->widget())) editor->findUsages(); } -void QmlJSEditorPlugin::renameUsages() +void QmlJSEditorPluginPrivate::renameUsages() { if (QmlJSEditorWidget *editor = qobject_cast(EditorManager::currentEditor()->widget())) editor->renameUsages(); } -void QmlJSEditorPlugin::reformatFile() +void QmlJSEditorPluginPrivate::reformatFile() { if (m_currentDocument) { QmlJS::Document::Ptr document = m_currentDocument->semanticInfo().document; @@ -281,15 +296,15 @@ void QmlJSEditorPlugin::reformatFile() } } -void QmlJSEditorPlugin::showContextPane() +void QmlJSEditorPluginPrivate::showContextPane() { if (QmlJSEditorWidget *editor = qobject_cast(EditorManager::currentEditor()->widget())) editor->showContextPane(); } -Command *QmlJSEditorPlugin::addToolAction(QAction *a, - Context &context, Id id, - ActionContainer *c1, const QString &keySequence) +Command *QmlJSEditorPluginPrivate::addToolAction(QAction *a, + Context &context, Id id, + ActionContainer *c1, const QString &keySequence) { Command *command = ActionManager::registerAction(a, id, context); if (!keySequence.isEmpty()) @@ -298,14 +313,14 @@ Command *QmlJSEditorPlugin::addToolAction(QAction *a, return command; } -QmlJSQuickFixAssistProvider *QmlJSEditorPlugin::quickFixAssistProvider() const +QmlJSQuickFixAssistProvider *QmlJSEditorPlugin::quickFixAssistProvider() { - return m_quickFixAssistProvider; + return &m_instance->d->m_quickFixAssistProvider; } -void QmlJSEditorPlugin::currentEditorChanged(IEditor *editor) +void QmlJSEditorPluginPrivate::currentEditorChanged(IEditor *editor) { - QmlJSEditorDocument *document = 0; + QmlJSEditorDocument *document = nullptr; if (editor) document = qobject_cast(editor->document()); @@ -314,26 +329,26 @@ void QmlJSEditorPlugin::currentEditorChanged(IEditor *editor) m_currentDocument = document; if (document) { connect(document->document(), &QTextDocument::contentsChanged, - this, &QmlJSEditorPlugin::checkCurrentEditorSemanticInfoUpToDate); + this, &QmlJSEditorPluginPrivate::checkCurrentEditorSemanticInfoUpToDate); connect(document, &QmlJSEditorDocument::semanticInfoUpdated, - this, &QmlJSEditorPlugin::checkCurrentEditorSemanticInfoUpToDate); + this, &QmlJSEditorPluginPrivate::checkCurrentEditorSemanticInfoUpToDate); } } -void QmlJSEditorPlugin::runSemanticScan() +void QmlJSEditorPluginPrivate::runSemanticScan() { - m_qmlTaskManager->updateSemanticMessagesNow(); + m_qmlTaskManager.updateSemanticMessagesNow(); TaskHub::setCategoryVisibility(Constants::TASK_CATEGORY_QML_ANALYSIS, true); TaskHub::requestPopup(); } -void QmlJSEditorPlugin::checkCurrentEditorSemanticInfoUpToDate() +void QmlJSEditorPluginPrivate::checkCurrentEditorSemanticInfoUpToDate() { const bool semanticInfoUpToDate = m_currentDocument && !m_currentDocument->isSemanticInfoOutdated(); m_reformatFileAction->setEnabled(semanticInfoUpToDate); } -void QmlJSEditorPlugin::autoFormatOnSave(Core::IDocument *document) +void QmlJSEditorPluginPrivate::autoFormatOnSave(IDocument *document) { if (!QmlJsEditingSettings::get().autoFormatOnSave()) return; @@ -344,12 +359,13 @@ void QmlJSEditorPlugin::autoFormatOnSave(Core::IDocument *document) // Check if file is contained in the current project (if wished) if (QmlJsEditingSettings::get().autoFormatOnlyCurrentProject()) { - const ProjectExplorer::Project *pro = ProjectExplorer::ProjectTree::currentProject(); - if (!pro || !pro->files(ProjectExplorer::Project::SourceFiles).contains(document->filePath())) + const Project *pro = ProjectTree::currentProject(); + if (!pro || !pro->files(Project::SourceFiles).contains(document->filePath())) return; } reformatFile(); } +} // namespace Internal } // namespace QmlJSEditor diff --git a/src/plugins/qmljseditor/qmljseditorplugin.h b/src/plugins/qmljseditor/qmljseditorplugin.h index b176866d950..de7484525a3 100644 --- a/src/plugins/qmljseditor/qmljseditorplugin.h +++ b/src/plugins/qmljseditor/qmljseditorplugin.h @@ -26,32 +26,13 @@ #pragma once #include -#include -#include - -#include - -QT_FORWARD_DECLARE_CLASS(QAction) namespace Utils { class JsonSchemaManager; } -namespace Core { -class Command; -class ActionContainer; -class IDocument; -class IEditor; -} - -namespace QmlJS { class ModelManagerInterface; } - namespace QmlJSEditor { - -class QmlJSEditorDocument; - namespace Internal { class QmlJSQuickFixAssistProvider; -class QmlTaskManager; class QmlJSEditorPlugin : public ExtensionSystem::IPlugin { @@ -60,44 +41,17 @@ class QmlJSEditorPlugin : public ExtensionSystem::IPlugin public: QmlJSEditorPlugin(); - virtual ~QmlJSEditorPlugin(); + ~QmlJSEditorPlugin() final; - // IPlugin - bool initialize(const QStringList &arguments, QString *errorMessage = 0); - void extensionsInitialized(); - ShutdownFlag aboutToShutdown(); - - static QmlJSEditorPlugin *instance() - { return m_instance; } - - QmlJSQuickFixAssistProvider *quickFixAssistProvider() const; - - Utils::JsonSchemaManager *jsonManager() const; - - void findUsages(); - void renameUsages(); - void reformatFile(); - void showContextPane(); + static QmlJSQuickFixAssistProvider *quickFixAssistProvider(); + static Utils::JsonSchemaManager *jsonManager(); private: - void currentEditorChanged(Core::IEditor *editor); - void runSemanticScan(); - void checkCurrentEditorSemanticInfoUpToDate(); - void autoFormatOnSave(Core::IDocument *document); + bool initialize(const QStringList &arguments, QString *errorMessage) final; + void extensionsInitialized() final; + ShutdownFlag aboutToShutdown() final; - Core::Command *addToolAction(QAction *a, Core::Context &context, Core::Id id, - Core::ActionContainer *c1, const QString &keySequence); - - static QmlJSEditorPlugin *m_instance; - - QmlJS::ModelManagerInterface *m_modelManager; - QmlJSQuickFixAssistProvider *m_quickFixAssistProvider; - QmlTaskManager *m_qmlTaskManager; - - QAction *m_reformatFileAction; - - QPointer m_currentDocument; - QScopedPointer m_jsonManager; + class QmlJSEditorPluginPrivate *d = nullptr; }; } // namespace Internal diff --git a/src/plugins/qmljseditor/qmljsquickfixassist.cpp b/src/plugins/qmljseditor/qmljsquickfixassist.cpp index c9bb01161d1..8effaa26cf1 100644 --- a/src/plugins/qmljseditor/qmljsquickfixassist.cpp +++ b/src/plugins/qmljseditor/qmljsquickfixassist.cpp @@ -80,12 +80,6 @@ class QmlJSQuickFixAssistProcessor : public IAssistProcessor // --------------------------- // QmlJSQuickFixAssistProvider // --------------------------- -QmlJSQuickFixAssistProvider::QmlJSQuickFixAssistProvider(QObject *parent) - : IAssistProvider(parent) -{} - -QmlJSQuickFixAssistProvider::~QmlJSQuickFixAssistProvider() -{} IAssistProvider::RunType QmlJSQuickFixAssistProvider::runType() const { diff --git a/src/plugins/qmljseditor/qmljsquickfixassist.h b/src/plugins/qmljseditor/qmljsquickfixassist.h index 1fd39d4e007..0f03844b2ef 100644 --- a/src/plugins/qmljseditor/qmljsquickfixassist.h +++ b/src/plugins/qmljseditor/qmljsquickfixassist.h @@ -53,8 +53,8 @@ private: class QmlJSQuickFixAssistProvider : public TextEditor::IAssistProvider { public: - QmlJSQuickFixAssistProvider(QObject *parent = nullptr); - ~QmlJSQuickFixAssistProvider(); + QmlJSQuickFixAssistProvider() = default; + ~QmlJSQuickFixAssistProvider() = default; IAssistProvider::RunType runType() const override; TextEditor::IAssistProcessor *createProcessor() const override; diff --git a/src/plugins/qmljseditor/qmljssemanticinfoupdater.cpp b/src/plugins/qmljseditor/qmljssemanticinfoupdater.cpp index 24f2c44aaed..7cd3b4704ca 100644 --- a/src/plugins/qmljseditor/qmljssemanticinfoupdater.cpp +++ b/src/plugins/qmljseditor/qmljssemanticinfoupdater.cpp @@ -125,8 +125,7 @@ QmlJSTools::SemanticInfo SemanticInfoUpdater::makeNewSemanticInfo(const QmlJS::D semanticInfo.setRootScopeChain(QSharedPointer(scopeChain)); if (doc->language() == Dialect::Json) { - Utils::JsonSchema *schema = - QmlJSEditorPlugin::instance()->jsonManager()->schemaForFile(doc->fileName()); + Utils::JsonSchema *schema = QmlJSEditorPlugin::jsonManager()->schemaForFile(doc->fileName()); if (schema) { JsonCheck jsonChecker(doc); semanticInfo.staticAnalysisMessages = jsonChecker(schema); diff --git a/src/plugins/qmljseditor/qmltaskmanager.cpp b/src/plugins/qmljseditor/qmltaskmanager.cpp index b9d27e2ee3f..85a99364057 100644 --- a/src/plugins/qmljseditor/qmltaskmanager.cpp +++ b/src/plugins/qmljseditor/qmltaskmanager.cpp @@ -47,9 +47,7 @@ using namespace Utils; namespace QmlJSEditor { namespace Internal { -QmlTaskManager::QmlTaskManager(QObject *parent) : - QObject(parent), - m_updatingSemantic(false) +QmlTaskManager::QmlTaskManager() { // displaying results incrementally leads to flickering // connect(&m_messageCollector, &QFutureWatcherBase::resultsReadyAt, diff --git a/src/plugins/qmljseditor/qmltaskmanager.h b/src/plugins/qmljseditor/qmltaskmanager.h index 415dcde393e..646aed7a220 100644 --- a/src/plugins/qmljseditor/qmltaskmanager.h +++ b/src/plugins/qmljseditor/qmltaskmanager.h @@ -43,7 +43,7 @@ class QmlTaskManager : public QObject { Q_OBJECT public: - QmlTaskManager(QObject *parent = 0); + QmlTaskManager(); void extensionsInitialized(); @@ -77,7 +77,7 @@ private: QHash > m_docsWithTasks; QFutureWatcher m_messageCollector; QTimer m_updateDelay; - bool m_updatingSemantic; + bool m_updatingSemantic = false; }; } // Internal diff --git a/src/plugins/qmljseditor/quicktoolbar.cpp b/src/plugins/qmljseditor/quicktoolbar.cpp index 9bc5b69855b..3122c43ceda 100644 --- a/src/plugins/qmljseditor/quicktoolbar.cpp +++ b/src/plugins/qmljseditor/quicktoolbar.cpp @@ -74,12 +74,8 @@ static inline const ObjectValue * getPropertyChangesTarget(Node *node, const Sco return 0; } -QuickToolBar::QuickToolBar(QObject *parent) - : ::IContextPane(parent) - , m_editorWidget(0) - , m_blockWriting(false) +QuickToolBar::QuickToolBar() { - m_node = 0; contextWidget(); m_propertyOrder diff --git a/src/plugins/qmljseditor/quicktoolbar.h b/src/plugins/qmljseditor/quicktoolbar.h index 6d75bb7bed2..42a71abbcea 100644 --- a/src/plugins/qmljseditor/quicktoolbar.h +++ b/src/plugins/qmljseditor/quicktoolbar.h @@ -38,7 +38,7 @@ class QuickToolBar : public QmlJS::IContextPane Q_OBJECT public: - QuickToolBar(QObject *parent = 0); + QuickToolBar(); ~QuickToolBar(); void apply(TextEditor::TextEditorWidget *widget, QmlJS::Document::Ptr document, const QmlJS::ScopeChain *scopeChain, QmlJS::AST::Node *node, bool update, bool force = false); bool isAvailable(TextEditor::TextEditorWidget *widget, QmlJS::Document::Ptr document, QmlJS::AST::Node *node); @@ -59,9 +59,9 @@ private: QmlEditorWidgets::ContextPaneWidget* contextWidget(); QPointer m_widget; QmlJS::Document::Ptr m_doc; - QmlJS::AST::Node *m_node; - TextEditor::TextEditorWidget *m_editorWidget; - bool m_blockWriting; + QmlJS::AST::Node *m_node = nullptr; + TextEditor::TextEditorWidget *m_editorWidget = nullptr; + bool m_blockWriting = false; QStringList m_propertyOrder; QStringList m_prototypes; QString m_oldType;