From 4b38f462f3fd95fe03649c19229bb97ae1bace73 Mon Sep 17 00:00:00 2001 From: Marco Bubke Date: Thu, 2 May 2024 19:47:34 +0200 Subject: [PATCH] QmlDesigner: Cleanup QScopedPointer std::unique_ptr is a clear super set of QScopedPointer with the same behavoir. There is Utils::UniqueObjectPtr too which prevents dangling pointer if the parent is set. Change-Id: I16c88f51b69f005445a079be494b44506271e53b Reviewed-by: Mahmoud Badri Reviewed-by: Reviewed-by: Tim Jenssen Reviewed-by: Qt CI Patch Build Bot --- .../assetslibrary/assetslibrarywidget.cpp | 4 +-- .../assetslibrary/assetslibrarywidget.h | 4 ++- .../collectioneditor/collectionwidget.cpp | 4 +-- .../collectioneditor/collectionwidget.h | 4 ++- .../collectioneditor/datastoremodelnode.cpp | 13 ++++---- .../componentcore/abstractaction.cpp | 4 +-- .../components/componentcore/abstractaction.h | 5 +-- .../componentcore/abstractactiongroup.cpp | 10 +++--- .../componentcore/abstractactiongroup.h | 5 +-- .../componentcore/designeractionmanager.cpp | 3 +- .../componentcore/designeractionmanager.h | 2 +- .../contentlibrary/contentlibrarywidget.cpp | 4 +-- .../contentlibrary/contentlibrarywidget.h | 6 +++- .../components/formeditor/dragtool.h | 1 - .../components/integration/designdocument.cpp | 20 +++++++---- .../components/integration/designdocument.h | 11 ++++--- .../integration/designdocumentview.cpp | 10 +++--- .../materialbrowser/materialbrowserwidget.cpp | 6 ++-- .../materialbrowser/materialbrowserwidget.h | 4 ++- .../materialeditorqmlbackend.cpp | 19 +++++------ .../materialeditor/materialeditorqmlbackend.h | 6 ++-- .../propertyeditorqmlbackend.cpp | 33 ++++++++----------- .../propertyeditor/propertyeditorqmlbackend.h | 8 +++-- .../propertyeditor/propertyeditorvalue.cpp | 1 - .../propertyeditor/propertyeditorview.cpp | 1 - .../texttool/textedititemwidget.cpp | 20 +++++------ .../components/texttool/textedititemwidget.h | 7 ++-- .../textureeditor/textureeditorqmlbackend.cpp | 24 +++++++------- .../textureeditor/textureeditorqmlbackend.h | 8 +++-- .../textureeditor/textureeditorview.cpp | 1 - .../timelineeditor/timelinepropertyitem.cpp | 1 - .../designercore/include/rewriterview.h | 8 ++--- .../instances/nodeinstanceview.cpp | 1 - .../designercore/model/qmlvisualnode.cpp | 10 +++--- .../designercore/model/rewriterview.cpp | 20 +++++------ .../designercore/model/stylesheetmerger.cpp | 16 +++++---- src/plugins/qmldesigner/designmodewidget.h | 1 - 37 files changed, 161 insertions(+), 144 deletions(-) diff --git a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.cpp b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.cpp index 4b270c8902d..5b6a2d76127 100644 --- a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.cpp +++ b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.cpp @@ -94,7 +94,7 @@ AssetsLibraryWidget::AssetsLibraryWidget(AsynchronousImageCache &asynchronousFon , m_assetsModel{new AssetsLibraryModel(this)} , m_assetsView{view} , m_createTextures{view} - , m_assetsWidget{new StudioQuickWidget(this)} + , m_assetsWidget{Utils::makeUniqueObjectPtr(this)} { setWindowTitle(tr("Assets Library", "Title of assets library widget")); setMinimumWidth(250); @@ -130,7 +130,7 @@ AssetsLibraryWidget::AssetsLibraryWidget(AsynchronousImageCache &asynchronousFon auto layout = new QVBoxLayout(this); layout->setContentsMargins({}); layout->setSpacing(0); - layout->addWidget(m_assetsWidget.data()); + layout->addWidget(m_assetsWidget.get()); updateSearch(); diff --git a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.h b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.h index 8b59ae07859..9e97080d4ac 100644 --- a/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.h +++ b/src/plugins/qmldesigner/components/assetslibrary/assetslibrarywidget.h @@ -8,6 +8,8 @@ #include +#include + #include #include #include @@ -137,7 +139,7 @@ private: AssetsLibraryView *m_assetsView = nullptr; CreateTextures m_createTextures = nullptr; - QScopedPointer m_assetsWidget; + Utils::UniqueObjectPtr m_assetsWidget; std::unique_ptr m_fontPreviewTooltipBackend; QShortcut *m_qmlSourceUpdateShortcut = nullptr; diff --git a/src/plugins/qmldesigner/components/collectioneditor/collectionwidget.cpp b/src/plugins/qmldesigner/components/collectioneditor/collectionwidget.cpp index 137486802aa..7a90264145c 100644 --- a/src/plugins/qmldesigner/components/collectioneditor/collectionwidget.cpp +++ b/src/plugins/qmldesigner/components/collectioneditor/collectionwidget.cpp @@ -59,7 +59,7 @@ CollectionWidget::CollectionWidget(CollectionView *view) , m_listModel(new CollectionListModel) , m_collectionDetailsModel(new CollectionDetailsModel) , m_collectionDetailsSortFilterModel(std::make_unique()) - , m_quickWidget(new StudioQuickWidget(this)) + , m_quickWidget(Utils::makeUniqueObjectPtr(this)) { setWindowTitle(tr("Model Editor", "Title of model editor widget")); @@ -84,7 +84,7 @@ CollectionWidget::CollectionWidget(CollectionView *view) auto layout = new QVBoxLayout(this); layout->setContentsMargins({}); layout->setSpacing(0); - layout->addWidget(m_quickWidget.data()); + layout->addWidget(m_quickWidget.get()); qmlRegisterAnonymousType("CollectionEditorBackend", 1); auto map = m_quickWidget->registerPropertyMap("CollectionEditorBackend"); diff --git a/src/plugins/qmldesigner/components/collectioneditor/collectionwidget.h b/src/plugins/qmldesigner/components/collectioneditor/collectionwidget.h index 56f5ff30edc..f62d4664720 100644 --- a/src/plugins/qmldesigner/components/collectioneditor/collectionwidget.h +++ b/src/plugins/qmldesigner/components/collectioneditor/collectionwidget.h @@ -7,6 +7,8 @@ #include +#include + class StudioQuickWidget; namespace QmlDesigner { @@ -73,7 +75,7 @@ private: QPointer m_collectionDetailsModel; QPointer m_iContext; std::unique_ptr m_collectionDetailsSortFilterModel; - QScopedPointer m_quickWidget; + Utils::UniqueObjectPtr m_quickWidget; bool m_targetNodeSelected = false; bool m_projectImportExists = false; bool m_dataStoreExists = false; diff --git a/src/plugins/qmldesigner/components/collectioneditor/datastoremodelnode.cpp b/src/plugins/qmldesigner/components/collectioneditor/datastoremodelnode.cpp index 5be9c20f9ed..d8b80061f32 100644 --- a/src/plugins/qmldesigner/components/collectioneditor/datastoremodelnode.cpp +++ b/src/plugins/qmldesigner/components/collectioneditor/datastoremodelnode.cpp @@ -31,7 +31,8 @@ #include #include #include -#include + +#include namespace { @@ -104,14 +105,14 @@ void setQmlContextToModel(QmlDesigner::Model *model, const QString &qmlContext) using namespace QmlDesigner; Q_ASSERT(model); - QScopedPointer textEdit(new QPlainTextEdit); - QScopedPointer modifier( - new NotIndentingTextEditModifier(textEdit.data())); + std::unique_ptr textEdit = std::make_unique(); + std::unique_ptr modifier = std::make_unique( + textEdit.get()); textEdit->hide(); textEdit->setPlainText(qmlContext); QmlDesigner::ExternalDependencies externalDependencies{QmlDesignerBasePlugin::settings()}; - QScopedPointer rewriter( - new RewriterView(externalDependencies, QmlDesigner::RewriterView::Validate)); + std::unique_ptr rewriter = std::make_unique( + externalDependencies, QmlDesigner::RewriterView::Validate); rewriter->setParent(model); rewriter->setTextModifier(modifier.get()); diff --git a/src/plugins/qmldesigner/components/componentcore/abstractaction.cpp b/src/plugins/qmldesigner/components/componentcore/abstractaction.cpp index 559e8ea69c6..3379d998349 100644 --- a/src/plugins/qmldesigner/components/componentcore/abstractaction.cpp +++ b/src/plugins/qmldesigner/components/componentcore/abstractaction.cpp @@ -8,7 +8,7 @@ namespace QmlDesigner { AbstractAction::AbstractAction(const QString &description) - : m_pureAction(new DefaultAction(description)) + : m_pureAction(std::make_unique(description)) { const Utils::Icon defaultIcon({ {":/utils/images/select.png", Utils::Theme::QmlDesigner_FormEditorForegroundColor}}, Utils::Icon::MenuTintedStyle); @@ -56,7 +56,7 @@ void AbstractAction::setCheckable(bool checkable) PureActionInterface *AbstractAction::pureAction() const { - return m_pureAction.data(); + return m_pureAction.get(); } SelectionContext AbstractAction::selectionContext() const diff --git a/src/plugins/qmldesigner/components/componentcore/abstractaction.h b/src/plugins/qmldesigner/components/componentcore/abstractaction.h index ca4cc582ce9..53b540cc7a3 100644 --- a/src/plugins/qmldesigner/components/componentcore/abstractaction.h +++ b/src/plugins/qmldesigner/components/componentcore/abstractaction.h @@ -6,7 +6,8 @@ #include "actioninterface.h" #include -#include + +#include namespace QmlDesigner { @@ -58,7 +59,7 @@ protected: SelectionContext selectionContext() const; private: - QScopedPointer m_pureAction; + std::unique_ptr m_pureAction; SelectionContext m_selectionContext; }; diff --git a/src/plugins/qmldesigner/components/componentcore/abstractactiongroup.cpp b/src/plugins/qmldesigner/components/componentcore/abstractactiongroup.cpp index 288b8e409de..5b340343e7d 100644 --- a/src/plugins/qmldesigner/components/componentcore/abstractactiongroup.cpp +++ b/src/plugins/qmldesigner/components/componentcore/abstractactiongroup.cpp @@ -8,14 +8,14 @@ namespace QmlDesigner { -AbstractActionGroup::AbstractActionGroup(const QString &displayName) : - m_displayName(displayName), - m_menu(new QmlEditorMenu) +AbstractActionGroup::AbstractActionGroup(const QString &displayName) + : m_displayName(displayName) + , m_menu(Utils::makeUniqueObjectPtr()) { m_menu->setTitle(displayName); m_action = m_menu->menuAction(); - QmlEditorMenu *qmlEditorMenu = qobject_cast(m_menu.data()); + QmlEditorMenu *qmlEditorMenu = qobject_cast(m_menu.get()); if (qmlEditorMenu) qmlEditorMenu->setIconsVisible(false); } @@ -32,7 +32,7 @@ QAction *AbstractActionGroup::action() const QMenu *AbstractActionGroup::menu() const { - return m_menu.data(); + return m_menu.get(); } SelectionContext AbstractActionGroup::selectionContext() const diff --git a/src/plugins/qmldesigner/components/componentcore/abstractactiongroup.h b/src/plugins/qmldesigner/components/componentcore/abstractactiongroup.h index dd89849ecfa..f239eeab3de 100644 --- a/src/plugins/qmldesigner/components/componentcore/abstractactiongroup.h +++ b/src/plugins/qmldesigner/components/componentcore/abstractactiongroup.h @@ -5,9 +5,10 @@ #include "actioninterface.h" +#include + #include #include -#include namespace QmlDesigner { @@ -29,7 +30,7 @@ public: private: const QString m_displayName; SelectionContext m_selectionContext; - QScopedPointer m_menu; + Utils::UniqueObjectPtr m_menu; QAction *m_action; }; diff --git a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp index 0722d2d5f81..fd2321f82a3 100644 --- a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp +++ b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.cpp @@ -2193,7 +2193,8 @@ void DesignerActionManager::addCustomTransitionEffectAction() void DesignerActionManager::setupIcons() { - m_designerIcons.reset(new DesignerIcons("qtds_propertyIconFont.ttf", designerIconResourcesPath())); + m_designerIcons = std::make_unique("qtds_propertyIconFont.ttf", + designerIconResourcesPath()); } QString DesignerActionManager::designerIconResourcesPath() const diff --git a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.h b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.h index 16d6219cd69..89505fcbe85 100644 --- a/src/plugins/qmldesigner/components/componentcore/designeractionmanager.h +++ b/src/plugins/qmldesigner/components/componentcore/designeractionmanager.h @@ -138,7 +138,7 @@ private: QList m_addResourceHandler; QList m_modelNodePreviewImageHandlers; ExternalDependenciesInterface &m_externalDependencies; - QScopedPointer m_designerIcons; + std::unique_ptr m_designerIcons; QList m_callBacks; }; diff --git a/src/plugins/qmldesigner/components/contentlibrary/contentlibrarywidget.cpp b/src/plugins/qmldesigner/components/contentlibrary/contentlibrarywidget.cpp index 0c680afa76f..96db7d7110d 100644 --- a/src/plugins/qmldesigner/components/contentlibrary/contentlibrarywidget.cpp +++ b/src/plugins/qmldesigner/components/contentlibrary/contentlibrarywidget.cpp @@ -123,7 +123,7 @@ bool ContentLibraryWidget::eventFilter(QObject *obj, QEvent *event) } ContentLibraryWidget::ContentLibraryWidget() - : m_quickWidget(new StudioQuickWidget(this)) + : m_quickWidget(Utils::makeUniqueObjectPtr(this)) , m_materialsModel(new ContentLibraryMaterialsModel(this)) , m_texturesModel(new ContentLibraryTexturesModel("Textures", this)) , m_environmentsModel(new ContentLibraryTexturesModel("Environments", this)) @@ -156,7 +156,7 @@ ContentLibraryWidget::ContentLibraryWidget() auto layout = new QVBoxLayout(this); layout->setContentsMargins({}); layout->setSpacing(0); - layout->addWidget(m_quickWidget.data()); + layout->addWidget(m_quickWidget.get()); updateSearch(); diff --git a/src/plugins/qmldesigner/components/contentlibrary/contentlibrarywidget.h b/src/plugins/qmldesigner/components/contentlibrary/contentlibrarywidget.h index 75339f02491..6f4cc300c91 100644 --- a/src/plugins/qmldesigner/components/contentlibrary/contentlibrarywidget.h +++ b/src/plugins/qmldesigner/components/contentlibrary/contentlibrarywidget.h @@ -4,7 +4,11 @@ #pragma once #include "createtexture.h" + #include + +#include + #include #include @@ -122,7 +126,7 @@ private: void populateTextureBundleModels(); void createImporter(); - QScopedPointer m_quickWidget; + Utils::UniqueObjectPtr m_quickWidget; QPointer m_materialsModel; QPointer m_texturesModel; QPointer m_environmentsModel; diff --git a/src/plugins/qmldesigner/components/formeditor/dragtool.h b/src/plugins/qmldesigner/components/formeditor/dragtool.h index 1cd2c9f4873..c1d5626d28d 100644 --- a/src/plugins/qmldesigner/components/formeditor/dragtool.h +++ b/src/plugins/qmldesigner/components/formeditor/dragtool.h @@ -7,7 +7,6 @@ #include "selectionindicator.h" #include -#include #include namespace QmlDesigner { diff --git a/src/plugins/qmldesigner/components/integration/designdocument.cpp b/src/plugins/qmldesigner/components/integration/designdocument.cpp index 804ac076e62..0b175916c9f 100644 --- a/src/plugins/qmldesigner/components/integration/designdocument.cpp +++ b/src/plugins/qmldesigner/components/integration/designdocument.cpp @@ -150,7 +150,10 @@ bool DesignDocument::loadInFileComponent(const ModelNode &componentNode) if (!componentNode.isRootNode()) { //change to subcomponent model - changeToInFileComponentModel(createComponentTextModifier(m_documentTextModifier.data(), rewriterView(), componentText, componentNode)); + changeToInFileComponentModel(createComponentTextModifier(m_documentTextModifier.get(), + rewriterView(), + componentText, + componentNode)); } return true; @@ -377,9 +380,12 @@ void DesignDocument::loadDocument(QPlainTextEdit *edit) m_documentTextModifier.reset(new BaseTextEditModifier(qobject_cast(plainTextEdit()))); - connect(m_documentTextModifier.data(), &TextModifier::textChanged, this, &DesignDocument::updateQrcFiles); + connect(m_documentTextModifier.get(), + &TextModifier::textChanged, + this, + &DesignDocument::updateQrcFiles); - m_rewriterView->setTextModifier(m_documentTextModifier.data()); + m_rewriterView->setTextModifier(m_documentTextModifier.get()); m_inFileComponentTextModifier.reset(); @@ -399,7 +405,7 @@ void DesignDocument::changeToDocumentModel() if (edit) edit->document()->clearUndoRedoStacks(); - m_rewriterView->setTextModifier(m_documentTextModifier.data()); + m_rewriterView->setTextModifier(m_documentTextModifier.get()); m_inFileComponentModel.reset(); m_inFileComponentTextModifier.reset(); @@ -432,7 +438,7 @@ bool DesignDocument::hasProject() const void DesignDocument::setModified() { - if (!m_documentTextModifier.isNull()) + if (m_documentTextModifier) m_documentTextModifier->textDocument()->setModified(true); } @@ -448,7 +454,7 @@ void DesignDocument::changeToInFileComponentModel(ComponentTextModifier *textMod m_inFileComponentModel = createInFileComponentModel(); - m_rewriterView->setTextModifier(m_inFileComponentTextModifier.data()); + m_rewriterView->setTextModifier(m_inFileComponentTextModifier.get()); viewManager().attachRewriterView(); viewManager().attachViewsExceptRewriterAndComponetView(); @@ -675,7 +681,7 @@ void DesignDocument::selectAll() RewriterView *DesignDocument::rewriterView() const { - return m_rewriterView.data(); + return m_rewriterView.get(); } void DesignDocument::setEditor(Core::IEditor *editor) diff --git a/src/plugins/qmldesigner/components/integration/designdocument.h b/src/plugins/qmldesigner/components/integration/designdocument.h index 52089d67c1b..1f67ff4b30b 100644 --- a/src/plugins/qmldesigner/components/integration/designdocument.h +++ b/src/plugins/qmldesigner/components/integration/designdocument.h @@ -16,9 +16,10 @@ #include #include - #include +#include + QT_BEGIN_NAMESPACE class QPlainTextEdit; QT_END_NAMESPACE @@ -143,12 +144,12 @@ private: // variables ModelPointer m_documentModel; ModelPointer m_inFileComponentModel; QPointer m_textEditor; - QScopedPointer m_documentTextModifier; - QScopedPointer m_inFileComponentTextModifier; + std::unique_ptr m_documentTextModifier; + std::unique_ptr m_inFileComponentTextModifier; #ifndef QDS_USE_PROJECTSTORAGE - QScopedPointer m_subComponentManager; + std::unique_ptr m_subComponentManager; #endif - QScopedPointer m_rewriterView; + std::unique_ptr m_rewriterView; bool m_documentLoaded; ProjectExplorer::Target *m_currentTarget; ProjectStorageDependencies m_projectStorageDependencies; diff --git a/src/plugins/qmldesigner/components/integration/designdocumentview.cpp b/src/plugins/qmldesigner/components/integration/designdocumentview.cpp index 6ef95bf4c45..d97b9ff06f9 100644 --- a/src/plugins/qmldesigner/components/integration/designdocumentview.cpp +++ b/src/plugins/qmldesigner/components/integration/designdocumentview.cpp @@ -23,6 +23,8 @@ #include #include +#include + namespace QmlDesigner { DesignDocumentView::DesignDocumentView(ExternalDependenciesInterface &externalDependencies) @@ -116,14 +118,14 @@ QString DesignDocumentView::toText() const textEdit.setPlainText(imports + QStringLiteral("Item {\n}\n")); NotIndentingTextEditModifier modifier(&textEdit); - QScopedPointer rewriterView( - new RewriterView(externalDependencies(), RewriterView::Amend)); + std::unique_ptr rewriterView = std::make_unique(externalDependencies(), + RewriterView::Amend); rewriterView->setCheckSemanticErrors(false); rewriterView->setPossibleImportsEnabled(false); rewriterView->setTextModifier(&modifier); - outputModel->setRewriterView(rewriterView.data()); + outputModel->setRewriterView(rewriterView.get()); - ModelMerger merger(rewriterView.data()); + ModelMerger merger(rewriterView.get()); merger.replaceModel(rootModelNode()); diff --git a/src/plugins/qmldesigner/components/materialbrowser/materialbrowserwidget.cpp b/src/plugins/qmldesigner/components/materialbrowser/materialbrowserwidget.cpp index 7cf0a875bcf..42268ee6fd1 100644 --- a/src/plugins/qmldesigner/components/materialbrowser/materialbrowserwidget.cpp +++ b/src/plugins/qmldesigner/components/materialbrowser/materialbrowserwidget.cpp @@ -150,7 +150,7 @@ MaterialBrowserWidget::MaterialBrowserWidget(AsynchronousImageCache &imageCache, : m_materialBrowserView(view) , m_materialBrowserModel(new MaterialBrowserModel(view, this)) , m_materialBrowserTexturesModel(new MaterialBrowserTexturesModel(view, this)) - , m_quickWidget(new StudioQuickWidget(this)) + , m_quickWidget(Utils::makeUniqueObjectPtr(this)) , m_previewImageProvider(new PreviewImageProvider()) { QImage defaultImage; @@ -179,7 +179,7 @@ MaterialBrowserWidget::MaterialBrowserWidget(AsynchronousImageCache &imageCache, auto layout = new QVBoxLayout(this); layout->setContentsMargins({}); layout->setSpacing(0); - layout->addWidget(m_quickWidget.data()); + layout->addWidget(m_quickWidget.get()); updateSearch(); @@ -411,7 +411,7 @@ void MaterialBrowserWidget::setIsDragging(bool val) StudioQuickWidget *MaterialBrowserWidget::quickWidget() const { - return m_quickWidget.data(); + return m_quickWidget.get(); } void MaterialBrowserWidget::clearPreviewCache() diff --git a/src/plugins/qmldesigner/components/materialbrowser/materialbrowserwidget.h b/src/plugins/qmldesigner/components/materialbrowser/materialbrowserwidget.h index 97c994e5652..c55d72c8f73 100644 --- a/src/plugins/qmldesigner/components/materialbrowser/materialbrowserwidget.h +++ b/src/plugins/qmldesigner/components/materialbrowser/materialbrowserwidget.h @@ -7,6 +7,8 @@ #include +#include + #include QT_BEGIN_NAMESPACE @@ -85,7 +87,7 @@ private: QPointer m_materialBrowserView; QPointer m_materialBrowserModel; QPointer m_materialBrowserTexturesModel; - QScopedPointer m_quickWidget; + Utils::UniqueObjectPtr m_quickWidget; QShortcut *m_qmlSourceUpdateShortcut = nullptr; PreviewImageProvider *m_previewImageProvider = nullptr; diff --git a/src/plugins/qmldesigner/components/materialeditor/materialeditorqmlbackend.cpp b/src/plugins/qmldesigner/components/materialeditor/materialeditorqmlbackend.cpp index ecc460ae510..0e508f8f360 100644 --- a/src/plugins/qmldesigner/components/materialeditor/materialeditorqmlbackend.cpp +++ b/src/plugins/qmldesigner/components/materialeditor/materialeditorqmlbackend.cpp @@ -80,8 +80,8 @@ public: MaterialEditorQmlBackend::MaterialEditorQmlBackend(MaterialEditorView *materialEditor) : m_quickWidget(Utils::makeUniqueObjectPtr()) - , m_materialEditorTransaction(new MaterialEditorTransaction(materialEditor)) - , m_contextObject(new MaterialEditorContextObject(m_quickWidget.get())) + , m_materialEditorTransaction(std::make_unique(materialEditor)) + , m_contextObject(std::make_unique(m_quickWidget.get())) , m_materialEditorImageProvider(new MaterialEditorImageProvider()) { m_quickWidget->setObjectName(Constants::OBJECT_NAME_MATERIAL_EDITOR); @@ -90,7 +90,7 @@ MaterialEditorQmlBackend::MaterialEditorQmlBackend(MaterialEditorView *materialE m_quickWidget->engine()->addImageProvider("materialEditor", m_materialEditorImageProvider); m_contextObject->setBackendValues(&m_backendValuesPropertyMap); m_contextObject->setModel(materialEditor->model()); - context()->setContextObject(m_contextObject.data()); + context()->setContextObject(m_contextObject.get()); QObject::connect(&m_backendValuesPropertyMap, &DesignerPropertyMap::valueChanged, materialEditor, &MaterialEditorView::changeValue); @@ -193,7 +193,7 @@ QQmlContext *MaterialEditorQmlBackend::context() const MaterialEditorContextObject *MaterialEditorQmlBackend::contextObject() const { - return m_contextObject.data(); + return m_contextObject.get(); } QQuickWidget *MaterialEditorQmlBackend::widget() const @@ -224,7 +224,7 @@ DesignerPropertyMap &MaterialEditorQmlBackend::backendValuesPropertyMap() MaterialEditorTransaction *MaterialEditorQmlBackend::materialEditorTransaction() const { - return m_materialEditorTransaction.data(); + return m_materialEditorTransaction.get(); } PropertyEditorValue *MaterialEditorQmlBackend::propertyValueForName(const QString &propertyName) @@ -267,12 +267,9 @@ void MaterialEditorQmlBackend::setup(const QmlObjectNode &selectedMaterialNode, // anchors m_backendAnchorBinding.setup(selectedMaterialNode.modelNode()); - context()->setContextProperties( - QVector{ - {{"anchorBackend"}, QVariant::fromValue(&m_backendAnchorBinding)}, - {{"transaction"}, QVariant::fromValue(m_materialEditorTransaction.data())} - } - ); + context()->setContextProperties(QVector{ + {{"anchorBackend"}, QVariant::fromValue(&m_backendAnchorBinding)}, + {{"transaction"}, QVariant::fromValue(m_materialEditorTransaction.get())}}); contextObject()->setSpecificsUrl(qmlSpecificsFile); contextObject()->setStateName(stateName); diff --git a/src/plugins/qmldesigner/components/materialeditor/materialeditorqmlbackend.h b/src/plugins/qmldesigner/components/materialeditor/materialeditorqmlbackend.h index 0792a635ca3..9fd5fc23992 100644 --- a/src/plugins/qmldesigner/components/materialeditor/materialeditorqmlbackend.h +++ b/src/plugins/qmldesigner/components/materialeditor/materialeditorqmlbackend.h @@ -11,6 +11,8 @@ #include +#include + class PropertyEditorValue; QT_BEGIN_NAMESPACE @@ -67,8 +69,8 @@ private: Utils::UniqueObjectPtr m_quickWidget = nullptr; QmlAnchorBindingProxy m_backendAnchorBinding; QmlModelNodeProxy m_backendModelNode; - QScopedPointer m_materialEditorTransaction; - QScopedPointer m_contextObject; + std::unique_ptr m_materialEditorTransaction; + std::unique_ptr m_contextObject; QPointer m_materialEditorImageProvider; }; diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp index eea53c3f5a1..c397d445b19 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.cpp @@ -83,16 +83,17 @@ namespace QmlDesigner { PropertyEditorQmlBackend::PropertyEditorQmlBackend(PropertyEditorView *propertyEditor, AsynchronousImageCache &imageCache) : m_view(Utils::makeUniqueObjectPtr(imageCache)) - , m_propertyEditorTransaction(new PropertyEditorTransaction(propertyEditor)) - , m_dummyPropertyEditorValue(new PropertyEditorValue()) - , m_contextObject(new PropertyEditorContextObject(m_view.get())) + , m_propertyEditorTransaction(std::make_unique(propertyEditor)) + , m_dummyPropertyEditorValue(std::make_unique()) + , m_contextObject(std::make_unique(m_view.get())) { m_view->engine()->setOutputWarningsToStandardError(QmlDesignerPlugin::instance() ->settings().value(DesignerSettingsKey::SHOW_PROPERTYEDITOR_WARNINGS).toBool()); m_view->engine()->addImportPath(propertyEditorResourcesPath() + "/imports"); m_dummyPropertyEditorValue->setValue(QLatin1String("#000000")); - context()->setContextProperty(QLatin1String("dummyBackendValue"), m_dummyPropertyEditorValue.data()); + context()->setContextProperty(QLatin1String("dummyBackendValue"), + m_dummyPropertyEditorValue.get()); m_contextObject->setBackendValues(&m_backendValuesPropertyMap); m_contextObject->setModel(propertyEditor->model()); m_contextObject->insertInQmlContext(context()); @@ -402,7 +403,7 @@ QQmlContext *PropertyEditorQmlBackend::context() PropertyEditorContextObject *PropertyEditorQmlBackend::contextObject() { - return m_contextObject.data(); + return m_contextObject.get(); } QQuickWidget *PropertyEditorQmlBackend::widget() @@ -432,7 +433,7 @@ DesignerPropertyMap &PropertyEditorQmlBackend::backendValuesPropertyMap() { } PropertyEditorTransaction *PropertyEditorQmlBackend::propertyEditorTransaction() { - return m_propertyEditorTransaction.data(); + return m_propertyEditorTransaction.get(); } PropertyEditorValue *PropertyEditorQmlBackend::propertyValueForName(const QString &propertyName) @@ -495,12 +496,9 @@ void PropertyEditorQmlBackend::setup(const QmlObjectNode &qmlObjectNode, const Q // anchors m_backendAnchorBinding.setup(qmlObjectNode.modelNode()); - context()->setContextProperties( - QVector{ - {{"anchorBackend"}, QVariant::fromValue(&m_backendAnchorBinding)}, - {{"transaction"}, QVariant::fromValue(m_propertyEditorTransaction.data())} - } - ); + context()->setContextProperties(QVector{ + {{"anchorBackend"}, QVariant::fromValue(&m_backendAnchorBinding)}, + {{"transaction"}, QVariant::fromValue(m_propertyEditorTransaction.get())}}); contextObject()->setHasMultiSelection( !qmlObjectNode.view()->singleSelectedModelNode().isValid()); @@ -592,13 +590,10 @@ void PropertyEditorQmlBackend::initialSetup(const TypeName &typeName, const QUrl QObject::connect(valueObject, &PropertyEditorValue::valueChanged, &backendValuesPropertyMap(), &DesignerPropertyMap::valueChanged); m_backendValuesPropertyMap.insert(QLatin1String("id"), QVariant::fromValue(valueObject)); - context()->setContextProperties( - QVector{ - {{"anchorBackend"}, QVariant::fromValue(&m_backendAnchorBinding)}, - {{"modelNodeBackend"}, QVariant::fromValue(&m_backendModelNode)}, - {{"transaction"}, QVariant::fromValue(m_propertyEditorTransaction.data())} - } - ); + context()->setContextProperties(QVector{ + {{"anchorBackend"}, QVariant::fromValue(&m_backendAnchorBinding)}, + {{"modelNodeBackend"}, QVariant::fromValue(&m_backendModelNode)}, + {{"transaction"}, QVariant::fromValue(m_propertyEditorTransaction.get())}}); contextObject()->setSpecificsUrl(qmlSpecificsFile); diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h index 120b7b4abcf..1c9b808ac3d 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorqmlbackend.h @@ -16,6 +16,8 @@ #include +#include + class PropertyEditorValue; namespace QmlDesigner { @@ -109,9 +111,9 @@ private: Utils::UniqueObjectPtr m_view = nullptr; QmlAnchorBindingProxy m_backendAnchorBinding; QmlModelNodeProxy m_backendModelNode; - QScopedPointer m_propertyEditorTransaction; - QScopedPointer m_dummyPropertyEditorValue; - QScopedPointer m_contextObject; + std::unique_ptr m_propertyEditorTransaction; + std::unique_ptr m_dummyPropertyEditorValue; + std::unique_ptr m_contextObject; }; } //QmlDesigner diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp index fbceb5dfea3..80ee2ea1723 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorvalue.cpp @@ -22,7 +22,6 @@ #include #include -#include #include namespace QmlDesigner { diff --git a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp index b22b39e238b..e0d5759617b 100644 --- a/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp +++ b/src/plugins/qmldesigner/components/propertyeditor/propertyeditorview.cpp @@ -38,7 +38,6 @@ #include #include #include -#include #include #include diff --git a/src/plugins/qmldesigner/components/texttool/textedititemwidget.cpp b/src/plugins/qmldesigner/components/texttool/textedititemwidget.cpp index b9c5868bd89..2861344d750 100644 --- a/src/plugins/qmldesigner/components/texttool/textedititemwidget.cpp +++ b/src/plugins/qmldesigner/components/texttool/textedititemwidget.cpp @@ -38,8 +38,8 @@ void TextEditItemWidget::paint(QPainter *painter, const QStyleOptionGraphicsItem QLineEdit* TextEditItemWidget::lineEdit() const { - if (m_lineEdit.isNull()) { - m_lineEdit.reset(new QLineEdit); + if (!m_lineEdit) { + m_lineEdit = std::make_unique(); m_lineEdit->setAlignment(Qt::AlignVCenter | Qt::AlignHCenter); QPalette palette = m_lineEdit->palette(); static QColor selectionColor = Utils::creatorTheme()->color(Utils::Theme::QmlDesigner_FormEditorSelectionColor); @@ -49,13 +49,13 @@ QLineEdit* TextEditItemWidget::lineEdit() const palette.setColor(QPalette::Text, Qt::black); m_lineEdit->setPalette(palette); } - return m_lineEdit.data(); + return m_lineEdit.get(); } QTextEdit* TextEditItemWidget::textEdit() const { - if (m_textEdit.isNull()) { - m_textEdit.reset(new QTextEdit); + if (!m_textEdit) { + m_textEdit = std::make_unique(); QPalette palette = m_textEdit->palette(); static QColor selectionColor = Utils::creatorTheme()->color(Utils::Theme::QmlDesigner_FormEditorSelectionColor); palette.setColor(QPalette::Highlight, selectionColor); @@ -65,7 +65,7 @@ QTextEdit* TextEditItemWidget::textEdit() const m_textEdit->setPalette(palette); } - return m_textEdit.data(); + return m_textEdit.get(); } void TextEditItemWidget::activateTextEdit(const QSize &maximumSize) @@ -83,19 +83,19 @@ void TextEditItemWidget::activateLineEdit() QString TextEditItemWidget::text() const { - if (widget() == m_lineEdit.data()) + if (widget() == m_lineEdit.get()) return m_lineEdit->text(); - else if (widget() == m_textEdit.data()) + else if (widget() == m_textEdit.get()) return m_textEdit->toPlainText(); return QString(); } void TextEditItemWidget::updateText(const QString &text) { - if (widget() == m_lineEdit.data()) { + if (widget() == m_lineEdit.get()) { m_lineEdit->setText(text); m_lineEdit->selectAll(); - } else if (widget() == m_textEdit.data()) { + } else if (widget() == m_textEdit.get()) { m_textEdit->setText(text); m_textEdit->selectAll(); } diff --git a/src/plugins/qmldesigner/components/texttool/textedititemwidget.h b/src/plugins/qmldesigner/components/texttool/textedititemwidget.h index 8aa6c409f93..f975f1a3daa 100644 --- a/src/plugins/qmldesigner/components/texttool/textedititemwidget.h +++ b/src/plugins/qmldesigner/components/texttool/textedititemwidget.h @@ -3,7 +3,8 @@ #pragma once #include -#include + +#include QT_BEGIN_NAMESPACE class QTextEdit; @@ -32,7 +33,7 @@ protected: QString text() const; private: - mutable QScopedPointer m_lineEdit; - mutable QScopedPointer m_textEdit; + mutable std::unique_ptr m_lineEdit; + mutable std::unique_ptr m_textEdit; }; } // namespace QmlDesigner diff --git a/src/plugins/qmldesigner/components/textureeditor/textureeditorqmlbackend.cpp b/src/plugins/qmldesigner/components/textureeditor/textureeditorqmlbackend.cpp index 972574554b0..415d943723d 100644 --- a/src/plugins/qmldesigner/components/textureeditor/textureeditorqmlbackend.cpp +++ b/src/plugins/qmldesigner/components/textureeditor/textureeditorqmlbackend.cpp @@ -42,10 +42,11 @@ static QObject *variantToQObject(const QVariant &value) namespace QmlDesigner { -TextureEditorQmlBackend::TextureEditorQmlBackend(TextureEditorView *textureEditor, AsynchronousImageCache &imageCache) - : m_quickWidget(new QQuickWidget) - , m_textureEditorTransaction(new TextureEditorTransaction(textureEditor)) - , m_contextObject(new TextureEditorContextObject(m_quickWidget->rootContext())) +TextureEditorQmlBackend::TextureEditorQmlBackend(TextureEditorView *textureEditor, + AsynchronousImageCache &imageCache) + : m_quickWidget(Utils::makeUniqueObjectPtr()) + , m_textureEditorTransaction(std::make_unique(textureEditor)) + , m_contextObject(std::make_unique(m_quickWidget->rootContext())) { QImage defaultImage; defaultImage.load(Utils::StyleHelper::dpiSpecificImageFile(":/textureeditor/images/texture_default.png")); @@ -56,7 +57,7 @@ TextureEditorQmlBackend::TextureEditorQmlBackend(TextureEditorView *textureEdito m_quickWidget->engine()->addImageProvider("qmldesigner_thumbnails", m_textureEditorImageProvider); m_contextObject->setBackendValues(&m_backendValuesPropertyMap); m_contextObject->setModel(textureEditor->model()); - context()->setContextObject(m_contextObject.data()); + context()->setContextObject(m_contextObject.get()); QObject::connect(&m_backendValuesPropertyMap, &DesignerPropertyMap::valueChanged, textureEditor, &TextureEditorView::changeValue); @@ -159,7 +160,7 @@ QQmlContext *TextureEditorQmlBackend::context() const TextureEditorContextObject *TextureEditorQmlBackend::contextObject() const { - return m_contextObject.data(); + return m_contextObject.get(); } QQuickWidget *TextureEditorQmlBackend::widget() const @@ -184,7 +185,7 @@ DesignerPropertyMap &TextureEditorQmlBackend::backendValuesPropertyMap() TextureEditorTransaction *TextureEditorQmlBackend::textureEditorTransaction() const { - return m_textureEditorTransaction.data(); + return m_textureEditorTransaction.get(); } PropertyEditorValue *TextureEditorQmlBackend::propertyValueForName(const QString &propertyName) @@ -227,12 +228,9 @@ void TextureEditorQmlBackend::setup(const QmlObjectNode &selectedTextureNode, co // anchors m_backendAnchorBinding.setup(selectedTextureNode.modelNode()); - context()->setContextProperties( - QVector{ - {{"anchorBackend"}, QVariant::fromValue(&m_backendAnchorBinding)}, - {{"transaction"}, QVariant::fromValue(m_textureEditorTransaction.data())} - } - ); + context()->setContextProperties(QVector{ + {{"anchorBackend"}, QVariant::fromValue(&m_backendAnchorBinding)}, + {{"transaction"}, QVariant::fromValue(m_textureEditorTransaction.get())}}); contextObject()->setSpecificsUrl(qmlSpecificsFile); contextObject()->setStateName(stateName); diff --git a/src/plugins/qmldesigner/components/textureeditor/textureeditorqmlbackend.h b/src/plugins/qmldesigner/components/textureeditor/textureeditorqmlbackend.h index c8a113f7d3d..f69c46a5698 100644 --- a/src/plugins/qmldesigner/components/textureeditor/textureeditorqmlbackend.h +++ b/src/plugins/qmldesigner/components/textureeditor/textureeditorqmlbackend.h @@ -11,6 +11,8 @@ #include +#include + class PropertyEditorValue; QT_BEGIN_NAMESPACE @@ -64,11 +66,11 @@ private: // this needs be destructed after m_quickWidget->engine() is destructed DesignerPropertyMap m_backendValuesPropertyMap; - Utils::UniqueObjectPtr m_quickWidget = nullptr; + Utils::UniqueObjectPtr m_quickWidget; QmlAnchorBindingProxy m_backendAnchorBinding; QmlModelNodeProxy m_backendModelNode; - QScopedPointer m_textureEditorTransaction; - QScopedPointer m_contextObject; + std::unique_ptr m_textureEditorTransaction; + std::unique_ptr m_contextObject; AssetImageProvider *m_textureEditorImageProvider = nullptr; }; diff --git a/src/plugins/qmldesigner/components/textureeditor/textureeditorview.cpp b/src/plugins/qmldesigner/components/textureeditor/textureeditorview.cpp index 4f2cc0f81f8..a637431c4dd 100644 --- a/src/plugins/qmldesigner/components/textureeditor/textureeditorview.cpp +++ b/src/plugins/qmldesigner/components/textureeditor/textureeditorview.cpp @@ -43,7 +43,6 @@ #include #include #include -#include #include #include #include diff --git a/src/plugins/qmldesigner/components/timelineeditor/timelinepropertyitem.cpp b/src/plugins/qmldesigner/components/timelineeditor/timelinepropertyitem.cpp index 698ef0f03bb..762bd85c8b4 100644 --- a/src/plugins/qmldesigner/components/timelineeditor/timelinepropertyitem.cpp +++ b/src/plugins/qmldesigner/components/timelineeditor/timelinepropertyitem.cpp @@ -35,7 +35,6 @@ #include #include #include -#include #include diff --git a/src/plugins/qmldesigner/designercore/include/rewriterview.h b/src/plugins/qmldesigner/designercore/include/rewriterview.h index 0134349682e..92c79c78631 100644 --- a/src/plugins/qmldesigner/designercore/include/rewriterview.h +++ b/src/plugins/qmldesigner/designercore/include/rewriterview.h @@ -8,11 +8,11 @@ #include "documentmessage.h" #include "rewritertransaction.h" -#include #include #include #include +#include namespace QmlJS { class Document; @@ -203,9 +203,9 @@ private: //variables bool m_checkLinkErrors = true; DifferenceHandling m_differenceHandling; - QScopedPointer m_positionStorage; - QScopedPointer m_modelToTextMerger; - QScopedPointer m_textToModelMerger; + std::unique_ptr m_positionStorage; + std::unique_ptr m_modelToTextMerger; + std::unique_ptr m_textToModelMerger; QList m_errors; QList m_warnings; RewriterTransaction m_removeDefaultPropertyTransaction; diff --git a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp index 71354edb92a..fd8c92d04d3 100644 --- a/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp +++ b/src/plugins/qmldesigner/designercore/instances/nodeinstanceview.cpp @@ -91,7 +91,6 @@ #include #include #include -#include #include #include diff --git a/src/plugins/qmldesigner/designercore/model/qmlvisualnode.cpp b/src/plugins/qmldesigner/designercore/model/qmlvisualnode.cpp index 1077c5bda8f..0c51c9a341e 100644 --- a/src/plugins/qmldesigner/designercore/model/qmlvisualnode.cpp +++ b/src/plugins/qmldesigner/designercore/model/qmlvisualnode.cpp @@ -24,6 +24,8 @@ #include #include +#include + namespace QmlDesigner { static char imagePlaceHolder[] = "qrc:/qtquickplugin/images/template_image.png"; @@ -288,17 +290,17 @@ static QmlObjectNode createQmlObjectNodeFromSource(AbstractView *view, textEdit.setPlainText(source); NotIndentingTextEditModifier modifier(&textEdit); - QScopedPointer rewriterView( - new RewriterView(view->externalDependencies(), RewriterView::Amend)); + std::unique_ptr rewriterView = std::make_unique( + view->externalDependencies(), RewriterView::Amend); rewriterView->setCheckSemanticErrors(false); rewriterView->setTextModifier(&modifier); rewriterView->setAllowComponentRoot(true); rewriterView->setPossibleImportsEnabled(false); - inputModel->setRewriterView(rewriterView.data()); + inputModel->setRewriterView(rewriterView.get()); if (rewriterView->errors().isEmpty() && rewriterView->rootModelNode().isValid()) { ModelNode rootModelNode = rewriterView->rootModelNode(); - inputModel->detachView(rewriterView.data()); + inputModel->detachView(rewriterView.get()); QmlVisualNode(rootModelNode).setPosition(position); ModelMerger merger(view); return merger.insertModel(rootModelNode); diff --git a/src/plugins/qmldesigner/designercore/model/rewriterview.cpp b/src/plugins/qmldesigner/designercore/model/rewriterview.cpp index 81c699ce43a..8905f95430c 100644 --- a/src/plugins/qmldesigner/designercore/model/rewriterview.cpp +++ b/src/plugins/qmldesigner/designercore/model/rewriterview.cpp @@ -58,9 +58,9 @@ RewriterView::RewriterView(ExternalDependenciesInterface &externalDependencies, DifferenceHandling differenceHandling) : AbstractView{externalDependencies} , m_differenceHandling(differenceHandling) - , m_positionStorage(new ModelNodePositionStorage) - , m_modelToTextMerger(new Internal::ModelToTextMerger(this)) - , m_textToModelMerger(new Internal::TextToModelMerger(this)) + , m_positionStorage(std::make_unique()) + , m_modelToTextMerger(std::make_unique(this)) + , m_textToModelMerger(std::make_unique(this)) { m_amendTimer.setSingleShot(true); @@ -80,12 +80,12 @@ RewriterView::~RewriterView() = default; Internal::ModelToTextMerger *RewriterView::modelToTextMerger() const { - return m_modelToTextMerger.data(); + return m_modelToTextMerger.get(); } Internal::TextToModelMerger *RewriterView::textToModelMerger() const { - return m_textToModelMerger.data(); + return m_textToModelMerger.get(); } void RewriterView::modelAttached(Model *model) @@ -94,7 +94,7 @@ void RewriterView::modelAttached(Model *model) AbstractView::modelAttached(model); - ModelAmender differenceHandler(m_textToModelMerger.data()); + ModelAmender differenceHandler(m_textToModelMerger.get()); const QString qmlSource = m_textModifier->text(); if (m_textToModelMerger->load(qmlSource, differenceHandler)) m_lastCorrectQmlSource = qmlSource; @@ -495,7 +495,7 @@ void RewriterView::amendQmlText() const QString newQmlText = m_textModifier->text(); - ModelAmender differenceHandler(m_textToModelMerger.data()); + ModelAmender differenceHandler(m_textToModelMerger.get()); if (m_textToModelMerger->load(newQmlText, differenceHandler)) m_lastCorrectQmlSource = newQmlText; emitCustomNotification(EndRewriterAmend); @@ -701,7 +701,7 @@ void RewriterView::forceAmend() Internal::ModelNodePositionStorage *RewriterView::positionStorage() const { - return m_positionStorage.data(); + return m_positionStorage.get(); } QList RewriterView::warnings() const @@ -758,7 +758,7 @@ void RewriterView::resetToLastCorrectQml() { m_textModifier->textDocument()->undo(); m_textModifier->textDocument()->clearUndoRedoStacks(QTextDocument::RedoStack); - ModelAmender differenceHandler(m_textToModelMerger.data()); + ModelAmender differenceHandler(m_textToModelMerger.get()); Internal::WriteLocker::unlock(model()); m_textToModelMerger->load(m_textModifier->text(), differenceHandler); Internal::WriteLocker::lock(model()); @@ -1155,7 +1155,7 @@ void RewriterView::qmlTextChanged() switch (m_differenceHandling) { case Validate: { - ModelValidator differenceHandler(m_textToModelMerger.data()); + ModelValidator differenceHandler(m_textToModelMerger.get()); if (m_textToModelMerger->load(newQmlText, differenceHandler)) m_lastCorrectQmlSource = newQmlText; break; diff --git a/src/plugins/qmldesigner/designercore/model/stylesheetmerger.cpp b/src/plugins/qmldesigner/designercore/model/stylesheetmerger.cpp index 16877b61db6..4f744d54e6c 100644 --- a/src/plugins/qmldesigner/designercore/model/stylesheetmerger.cpp +++ b/src/plugins/qmldesigner/designercore/model/stylesheetmerger.cpp @@ -23,6 +23,8 @@ #include #include +#include + namespace { QPoint pointForModelNode(const QmlDesigner::ModelNode &node) @@ -641,10 +643,10 @@ void StylesheetMerger::styleMerge(const QString &qmlTemplateString, textEditTemplate.setPlainText(imports + qmlTemplateString); NotIndentingTextEditModifier textModifierTemplate(&textEditTemplate); - QScopedPointer templateRewriterView( - new RewriterView(externalDependencies, RewriterView::Amend)); + std::unique_ptr templateRewriterView = std::make_unique( + externalDependencies, RewriterView::Amend); templateRewriterView->setTextModifier(&textModifierTemplate); - templateModel->attachView(templateRewriterView.data()); + templateModel->attachView(templateRewriterView.get()); templateRewriterView->setCheckSemanticErrors(false); templateRewriterView->setPossibleImportsEnabled(false); @@ -665,12 +667,12 @@ void StylesheetMerger::styleMerge(const QString &qmlTemplateString, textEditStyle.setPlainText(parentRewriterView->textModifierContent()); NotIndentingTextEditModifier textModifierStyle(&textEditStyle); - QScopedPointer styleRewriterView( - new RewriterView(externalDependencies, RewriterView::Amend)); + std::unique_ptr styleRewriterView = std::make_unique( + externalDependencies, RewriterView::Amend); styleRewriterView->setTextModifier(&textModifierStyle); - styleModel->attachView(styleRewriterView.data()); + styleModel->attachView(styleRewriterView.get()); - StylesheetMerger merger(templateRewriterView.data(), styleRewriterView.data()); + StylesheetMerger merger(templateRewriterView.get(), styleRewriterView.get()); try { merger.merge(); diff --git a/src/plugins/qmldesigner/designmodewidget.h b/src/plugins/qmldesigner/designmodewidget.h index 464994b7e34..881335da75c 100644 --- a/src/plugins/qmldesigner/designmodewidget.h +++ b/src/plugins/qmldesigner/designmodewidget.h @@ -11,7 +11,6 @@ #include #include -#include #include #include