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 <mahmoud.badri@qt.io>
Reviewed-by: <github-actions-qt-creator@cristianadam.eu>
Reviewed-by: Tim Jenssen <tim.jenssen@qt.io>
Reviewed-by: Qt CI Patch Build Bot <ci_patchbuild_bot@qt.io>
This commit is contained in:
Marco Bubke
2024-05-02 19:47:34 +02:00
committed by Tim Jenssen
parent 688e697fc0
commit 4b38f462f3
37 changed files with 161 additions and 144 deletions

View File

@@ -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<StudioQuickWidget>(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();

View File

@@ -8,6 +8,8 @@
#include <coreplugin/icontext.h>
#include <utils/uniqueobjectptr.h>
#include <QFrame>
#include <QQmlPropertyMap>
#include <QQuickWidget>
@@ -137,7 +139,7 @@ private:
AssetsLibraryView *m_assetsView = nullptr;
CreateTextures m_createTextures = nullptr;
QScopedPointer<StudioQuickWidget> m_assetsWidget;
Utils::UniqueObjectPtr<StudioQuickWidget> m_assetsWidget;
std::unique_ptr<PreviewTooltipBackend> m_fontPreviewTooltipBackend;
QShortcut *m_qmlSourceUpdateShortcut = nullptr;

View File

@@ -59,7 +59,7 @@ CollectionWidget::CollectionWidget(CollectionView *view)
, m_listModel(new CollectionListModel)
, m_collectionDetailsModel(new CollectionDetailsModel)
, m_collectionDetailsSortFilterModel(std::make_unique<CollectionDetailsSortFilterModel>())
, m_quickWidget(new StudioQuickWidget(this))
, m_quickWidget(Utils::makeUniqueObjectPtr<StudioQuickWidget>(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<CollectionWidget>("CollectionEditorBackend", 1);
auto map = m_quickWidget->registerPropertyMap("CollectionEditorBackend");

View File

@@ -7,6 +7,8 @@
#include <coreplugin/icontext.h>
#include <utils/uniqueobjectptr.h>
class StudioQuickWidget;
namespace QmlDesigner {
@@ -73,7 +75,7 @@ private:
QPointer<CollectionDetailsModel> m_collectionDetailsModel;
QPointer<Core::IContext> m_iContext;
std::unique_ptr<CollectionDetailsSortFilterModel> m_collectionDetailsSortFilterModel;
QScopedPointer<StudioQuickWidget> m_quickWidget;
Utils::UniqueObjectPtr<StudioQuickWidget> m_quickWidget;
bool m_targetNodeSelected = false;
bool m_projectImportExists = false;
bool m_dataStoreExists = false;

View File

@@ -31,7 +31,8 @@
#include <QPlainTextEdit>
#include <QRegularExpression>
#include <QRegularExpressionMatch>
#include <QScopedPointer>
#include <memory>
namespace {
@@ -104,14 +105,14 @@ void setQmlContextToModel(QmlDesigner::Model *model, const QString &qmlContext)
using namespace QmlDesigner;
Q_ASSERT(model);
QScopedPointer<QPlainTextEdit> textEdit(new QPlainTextEdit);
QScopedPointer<NotIndentingTextEditModifier> modifier(
new NotIndentingTextEditModifier(textEdit.data()));
std::unique_ptr<QPlainTextEdit> textEdit = std::make_unique<QPlainTextEdit>();
std::unique_ptr<NotIndentingTextEditModifier> modifier = std::make_unique<NotIndentingTextEditModifier>(
textEdit.get());
textEdit->hide();
textEdit->setPlainText(qmlContext);
QmlDesigner::ExternalDependencies externalDependencies{QmlDesignerBasePlugin::settings()};
QScopedPointer<RewriterView> rewriter(
new RewriterView(externalDependencies, QmlDesigner::RewriterView::Validate));
std::unique_ptr<RewriterView> rewriter = std::make_unique<RewriterView>(
externalDependencies, QmlDesigner::RewriterView::Validate);
rewriter->setParent(model);
rewriter->setTextModifier(modifier.get());

View File

@@ -8,7 +8,7 @@
namespace QmlDesigner {
AbstractAction::AbstractAction(const QString &description)
: m_pureAction(new DefaultAction(description))
: m_pureAction(std::make_unique<DefaultAction>(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

View File

@@ -6,7 +6,8 @@
#include "actioninterface.h"
#include <QAction>
#include <QScopedPointer>
#include <memory>
namespace QmlDesigner {
@@ -58,7 +59,7 @@ protected:
SelectionContext selectionContext() const;
private:
QScopedPointer<PureActionInterface> m_pureAction;
std::unique_ptr<PureActionInterface> m_pureAction;
SelectionContext m_selectionContext;
};

View File

@@ -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<QmlEditorMenu>())
{
m_menu->setTitle(displayName);
m_action = m_menu->menuAction();
QmlEditorMenu *qmlEditorMenu = qobject_cast<QmlEditorMenu *>(m_menu.data());
QmlEditorMenu *qmlEditorMenu = qobject_cast<QmlEditorMenu *>(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

View File

@@ -5,9 +5,10 @@
#include "actioninterface.h"
#include <utils/uniqueobjectptr.h>
#include <QAction>
#include <QMenu>
#include <QScopedPointer>
namespace QmlDesigner {
@@ -29,7 +30,7 @@ public:
private:
const QString m_displayName;
SelectionContext m_selectionContext;
QScopedPointer<QMenu> m_menu;
Utils::UniqueObjectPtr<QMenu> m_menu;
QAction *m_action;
};

View File

@@ -2193,7 +2193,8 @@ void DesignerActionManager::addCustomTransitionEffectAction()
void DesignerActionManager::setupIcons()
{
m_designerIcons.reset(new DesignerIcons("qtds_propertyIconFont.ttf", designerIconResourcesPath()));
m_designerIcons = std::make_unique<DesignerIcons>("qtds_propertyIconFont.ttf",
designerIconResourcesPath());
}
QString DesignerActionManager::designerIconResourcesPath() const

View File

@@ -138,7 +138,7 @@ private:
QList<AddResourceHandler> m_addResourceHandler;
QList<ModelNodePreviewImageHandler> m_modelNodePreviewImageHandlers;
ExternalDependenciesInterface &m_externalDependencies;
QScopedPointer<DesignerIcons> m_designerIcons;
std::unique_ptr<DesignerIcons> m_designerIcons;
QList<ActionAddedInterface> m_callBacks;
};

View File

@@ -123,7 +123,7 @@ bool ContentLibraryWidget::eventFilter(QObject *obj, QEvent *event)
}
ContentLibraryWidget::ContentLibraryWidget()
: m_quickWidget(new StudioQuickWidget(this))
: m_quickWidget(Utils::makeUniqueObjectPtr<StudioQuickWidget>(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();

View File

@@ -4,7 +4,11 @@
#pragma once
#include "createtexture.h"
#include <modelfwd.h>
#include <utils/uniqueobjectptr.h>
#include <QFrame>
#include <QPointer>
@@ -122,7 +126,7 @@ private:
void populateTextureBundleModels();
void createImporter();
QScopedPointer<StudioQuickWidget> m_quickWidget;
Utils::UniqueObjectPtr<StudioQuickWidget> m_quickWidget;
QPointer<ContentLibraryMaterialsModel> m_materialsModel;
QPointer<ContentLibraryTexturesModel> m_texturesModel;
QPointer<ContentLibraryTexturesModel> m_environmentsModel;

View File

@@ -7,7 +7,6 @@
#include "selectionindicator.h"
#include <QObject>
#include <QScopedPointer>
#include <QPointer>
namespace QmlDesigner {

View File

@@ -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<TextEditor::TextEditorWidget *>(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)

View File

@@ -16,9 +16,10 @@
#include <QObject>
#include <QString>
#include <QStackedWidget>
#include <memory>
QT_BEGIN_NAMESPACE
class QPlainTextEdit;
QT_END_NAMESPACE
@@ -143,12 +144,12 @@ private: // variables
ModelPointer m_documentModel;
ModelPointer m_inFileComponentModel;
QPointer<Core::IEditor> m_textEditor;
QScopedPointer<BaseTextEditModifier> m_documentTextModifier;
QScopedPointer<ComponentTextModifier> m_inFileComponentTextModifier;
std::unique_ptr<BaseTextEditModifier> m_documentTextModifier;
std::unique_ptr<ComponentTextModifier> m_inFileComponentTextModifier;
#ifndef QDS_USE_PROJECTSTORAGE
QScopedPointer<SubComponentManager> m_subComponentManager;
std::unique_ptr<SubComponentManager> m_subComponentManager;
#endif
QScopedPointer<RewriterView> m_rewriterView;
std::unique_ptr<RewriterView> m_rewriterView;
bool m_documentLoaded;
ProjectExplorer::Target *m_currentTarget;
ProjectStorageDependencies m_projectStorageDependencies;

View File

@@ -23,6 +23,8 @@
#include <utils/algorithm.h>
#include <utils/qtcassert.h>
#include <memory>
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> rewriterView(
new RewriterView(externalDependencies(), RewriterView::Amend));
std::unique_ptr<RewriterView> rewriterView = std::make_unique<RewriterView>(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());

View File

@@ -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<StudioQuickWidget>(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()

View File

@@ -7,6 +7,8 @@
#include <coreplugin/icontext.h>
#include <utils/uniqueobjectptr.h>
#include <QFrame>
QT_BEGIN_NAMESPACE
@@ -85,7 +87,7 @@ private:
QPointer<MaterialBrowserView> m_materialBrowserView;
QPointer<MaterialBrowserModel> m_materialBrowserModel;
QPointer<MaterialBrowserTexturesModel> m_materialBrowserTexturesModel;
QScopedPointer<StudioQuickWidget> m_quickWidget;
Utils::UniqueObjectPtr<StudioQuickWidget> m_quickWidget;
QShortcut *m_qmlSourceUpdateShortcut = nullptr;
PreviewImageProvider *m_previewImageProvider = nullptr;

View File

@@ -80,8 +80,8 @@ public:
MaterialEditorQmlBackend::MaterialEditorQmlBackend(MaterialEditorView *materialEditor)
: m_quickWidget(Utils::makeUniqueObjectPtr<QQuickWidget>())
, m_materialEditorTransaction(new MaterialEditorTransaction(materialEditor))
, m_contextObject(new MaterialEditorContextObject(m_quickWidget.get()))
, m_materialEditorTransaction(std::make_unique<MaterialEditorTransaction>(materialEditor))
, m_contextObject(std::make_unique<MaterialEditorContextObject>(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<QQmlContext::PropertyPair>{
context()->setContextProperties(QVector<QQmlContext::PropertyPair>{
{{"anchorBackend"}, QVariant::fromValue(&m_backendAnchorBinding)},
{{"transaction"}, QVariant::fromValue(m_materialEditorTransaction.data())}
}
);
{{"transaction"}, QVariant::fromValue(m_materialEditorTransaction.get())}});
contextObject()->setSpecificsUrl(qmlSpecificsFile);
contextObject()->setStateName(stateName);

View File

@@ -11,6 +11,8 @@
#include <nodemetainfo.h>
#include <memory>
class PropertyEditorValue;
QT_BEGIN_NAMESPACE
@@ -67,8 +69,8 @@ private:
Utils::UniqueObjectPtr<QQuickWidget> m_quickWidget = nullptr;
QmlAnchorBindingProxy m_backendAnchorBinding;
QmlModelNodeProxy m_backendModelNode;
QScopedPointer<MaterialEditorTransaction> m_materialEditorTransaction;
QScopedPointer<MaterialEditorContextObject> m_contextObject;
std::unique_ptr<MaterialEditorTransaction> m_materialEditorTransaction;
std::unique_ptr<MaterialEditorContextObject> m_contextObject;
QPointer<MaterialEditorImageProvider> m_materialEditorImageProvider;
};

View File

@@ -83,16 +83,17 @@ namespace QmlDesigner {
PropertyEditorQmlBackend::PropertyEditorQmlBackend(PropertyEditorView *propertyEditor,
AsynchronousImageCache &imageCache)
: m_view(Utils::makeUniqueObjectPtr<Quick2PropertyEditorView>(imageCache))
, m_propertyEditorTransaction(new PropertyEditorTransaction(propertyEditor))
, m_dummyPropertyEditorValue(new PropertyEditorValue())
, m_contextObject(new PropertyEditorContextObject(m_view.get()))
, m_propertyEditorTransaction(std::make_unique<PropertyEditorTransaction>(propertyEditor))
, m_dummyPropertyEditorValue(std::make_unique<PropertyEditorValue>())
, m_contextObject(std::make_unique<PropertyEditorContextObject>(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<QQmlContext::PropertyPair>{
context()->setContextProperties(QVector<QQmlContext::PropertyPair>{
{{"anchorBackend"}, QVariant::fromValue(&m_backendAnchorBinding)},
{{"transaction"}, QVariant::fromValue(m_propertyEditorTransaction.data())}
}
);
{{"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<QQmlContext::PropertyPair>{
context()->setContextProperties(QVector<QQmlContext::PropertyPair>{
{{"anchorBackend"}, QVariant::fromValue(&m_backendAnchorBinding)},
{{"modelNodeBackend"}, QVariant::fromValue(&m_backendModelNode)},
{{"transaction"}, QVariant::fromValue(m_propertyEditorTransaction.data())}
}
);
{{"transaction"}, QVariant::fromValue(m_propertyEditorTransaction.get())}});
contextObject()->setSpecificsUrl(qmlSpecificsFile);

View File

@@ -16,6 +16,8 @@
#include <QQmlPropertyMap>
#include <memory>
class PropertyEditorValue;
namespace QmlDesigner {
@@ -109,9 +111,9 @@ private:
Utils::UniqueObjectPtr<Quick2PropertyEditorView> m_view = nullptr;
QmlAnchorBindingProxy m_backendAnchorBinding;
QmlModelNodeProxy m_backendModelNode;
QScopedPointer<PropertyEditorTransaction> m_propertyEditorTransaction;
QScopedPointer<PropertyEditorValue> m_dummyPropertyEditorValue;
QScopedPointer<PropertyEditorContextObject> m_contextObject;
std::unique_ptr<PropertyEditorTransaction> m_propertyEditorTransaction;
std::unique_ptr<PropertyEditorValue> m_dummyPropertyEditorValue;
std::unique_ptr<PropertyEditorContextObject> m_contextObject;
};
} //QmlDesigner

View File

@@ -22,7 +22,6 @@
#include <utils/qtcassert.h>
#include <QRegularExpression>
#include <QScopedPointer>
#include <QUrl>
namespace QmlDesigner {

View File

@@ -38,7 +38,6 @@
#include <QFileSystemWatcher>
#include <QQuickItem>
#include <QScopeGuard>
#include <QScopedPointer>
#include <QShortcut>
#include <QTimer>

View File

@@ -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<QLineEdit>();
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<QTextEdit>();
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();
}

View File

@@ -3,7 +3,8 @@
#pragma once
#include <QGraphicsProxyWidget>
#include <QScopedPointer>
#include <memory>
QT_BEGIN_NAMESPACE
class QTextEdit;
@@ -32,7 +33,7 @@ protected:
QString text() const;
private:
mutable QScopedPointer<QLineEdit> m_lineEdit;
mutable QScopedPointer<QTextEdit> m_textEdit;
mutable std::unique_ptr<QLineEdit> m_lineEdit;
mutable std::unique_ptr<QTextEdit> m_textEdit;
};
} // namespace QmlDesigner

View File

@@ -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<QQuickWidget>())
, m_textureEditorTransaction(std::make_unique<TextureEditorTransaction>(textureEditor))
, m_contextObject(std::make_unique<TextureEditorContextObject>(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<QQmlContext::PropertyPair>{
context()->setContextProperties(QVector<QQmlContext::PropertyPair>{
{{"anchorBackend"}, QVariant::fromValue(&m_backendAnchorBinding)},
{{"transaction"}, QVariant::fromValue(m_textureEditorTransaction.data())}
}
);
{{"transaction"}, QVariant::fromValue(m_textureEditorTransaction.get())}});
contextObject()->setSpecificsUrl(qmlSpecificsFile);
contextObject()->setStateName(stateName);

View File

@@ -11,6 +11,8 @@
#include <nodemetainfo.h>
#include <memory>
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<QQuickWidget> m_quickWidget = nullptr;
Utils::UniqueObjectPtr<QQuickWidget> m_quickWidget;
QmlAnchorBindingProxy m_backendAnchorBinding;
QmlModelNodeProxy m_backendModelNode;
QScopedPointer<TextureEditorTransaction> m_textureEditorTransaction;
QScopedPointer<TextureEditorContextObject> m_contextObject;
std::unique_ptr<TextureEditorTransaction> m_textureEditorTransaction;
std::unique_ptr<TextureEditorContextObject> m_contextObject;
AssetImageProvider *m_textureEditorImageProvider = nullptr;
};

View File

@@ -43,7 +43,6 @@
#include <QFileInfo>
#include <QQuickWidget>
#include <QQuickItem>
#include <QScopedPointer>
#include <QStackedWidget>
#include <QShortcut>
#include <QTimer>

View File

@@ -35,7 +35,6 @@
#include <QLineEdit>
#include <QMenu>
#include <QPainter>
#include <QScopedPointer>
#include <algorithm>

View File

@@ -8,11 +8,11 @@
#include "documentmessage.h"
#include "rewritertransaction.h"
#include <QScopedPointer>
#include <QTimer>
#include <QUrl>
#include <functional>
#include <memory>
namespace QmlJS {
class Document;
@@ -203,9 +203,9 @@ private: //variables
bool m_checkLinkErrors = true;
DifferenceHandling m_differenceHandling;
QScopedPointer<Internal::ModelNodePositionStorage> m_positionStorage;
QScopedPointer<Internal::ModelToTextMerger> m_modelToTextMerger;
QScopedPointer<Internal::TextToModelMerger> m_textToModelMerger;
std::unique_ptr<Internal::ModelNodePositionStorage> m_positionStorage;
std::unique_ptr<Internal::ModelToTextMerger> m_modelToTextMerger;
std::unique_ptr<Internal::TextToModelMerger> m_textToModelMerger;
QList<DocumentMessage> m_errors;
QList<DocumentMessage> m_warnings;
RewriterTransaction m_removeDefaultPropertyTransaction;

View File

@@ -91,7 +91,6 @@
#include <QMultiHash>
#include <QPainter>
#include <QPicture>
#include <QScopedPointer>
#include <QTimerEvent>
#include <QUrl>

View File

@@ -24,6 +24,8 @@
#include <QDir>
#include <QRandomGenerator>
#include <memory>
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> rewriterView(
new RewriterView(view->externalDependencies(), RewriterView::Amend));
std::unique_ptr<RewriterView> rewriterView = std::make_unique<RewriterView>(
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);

View File

@@ -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<ModelNodePositionStorage>())
, m_modelToTextMerger(std::make_unique<Internal::ModelToTextMerger>(this))
, m_textToModelMerger(std::make_unique<Internal::TextToModelMerger>(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<DocumentMessage> 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;

View File

@@ -23,6 +23,8 @@
#include <QQueue>
#include <QRegularExpression>
#include <memory>
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<RewriterView> templateRewriterView(
new RewriterView(externalDependencies, RewriterView::Amend));
std::unique_ptr<RewriterView> templateRewriterView = std::make_unique<RewriterView>(
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<RewriterView> styleRewriterView(
new RewriterView(externalDependencies, RewriterView::Amend));
std::unique_ptr<RewriterView> styleRewriterView = std::make_unique<RewriterView>(
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();

View File

@@ -11,7 +11,6 @@
#include <QWidget>
#include <QMainWindow>
#include <QScopedPointer>
#include <advanceddockingsystem/dockmanager.h>
#include <annotationeditor/globalannotationeditor.h>