forked from qt-creator/qt-creator
CustomWizard: Replace QSharedPointer with std::shared_ptr
According to https://wiki.qt.io/Things_To_Look_Out_For_In_Reviews QSharedPointer impl is poor and it's going to be removed from Qt 7. Change-Id: I7b7a715c1e2b8092ce7cb5f3686c3a3a02e0ad9e Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -78,8 +78,8 @@ class CustomWizardPrivate {
|
|||||||
public:
|
public:
|
||||||
CustomWizardPrivate() : m_context(new CustomWizardContext) {}
|
CustomWizardPrivate() : m_context(new CustomWizardContext) {}
|
||||||
|
|
||||||
QSharedPointer<CustomWizardParameters> m_parameters;
|
std::shared_ptr<CustomWizardParameters> m_parameters;
|
||||||
QSharedPointer<CustomWizardContext> m_context;
|
std::shared_ptr<CustomWizardContext> m_context;
|
||||||
static int verbose;
|
static int verbose;
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ void CustomWizard::setParameters(const CustomWizardParametersPtr &p)
|
|||||||
|
|
||||||
BaseFileWizard *CustomWizard::create(QWidget *parent, const WizardDialogParameters &p) const
|
BaseFileWizard *CustomWizard::create(QWidget *parent, const WizardDialogParameters &p) const
|
||||||
{
|
{
|
||||||
QTC_ASSERT(!d->m_parameters.isNull(), return nullptr);
|
QTC_ASSERT(d->m_parameters, return nullptr);
|
||||||
auto wizard = new BaseFileWizard(this, p.extraValues(), parent);
|
auto wizard = new BaseFileWizard(this, p.extraValues(), parent);
|
||||||
|
|
||||||
d->m_context->reset();
|
d->m_context->reset();
|
||||||
@@ -217,8 +217,8 @@ template <class WizardPage>
|
|||||||
|
|
||||||
// Determine where to run the generator script. The user may specify
|
// Determine where to run the generator script. The user may specify
|
||||||
// an expression subject to field replacement, default is the target path.
|
// an expression subject to field replacement, default is the target path.
|
||||||
static inline QString scriptWorkingDirectory(const QSharedPointer<CustomWizardContext> &ctx,
|
static inline QString scriptWorkingDirectory(const std::shared_ptr<CustomWizardContext> &ctx,
|
||||||
const QSharedPointer<CustomWizardParameters> &p)
|
const std::shared_ptr<CustomWizardParameters> &p)
|
||||||
{
|
{
|
||||||
if (p->filesGeneratorScriptWorkingDirectory.isEmpty())
|
if (p->filesGeneratorScriptWorkingDirectory.isEmpty())
|
||||||
return ctx->targetPath.toString();
|
return ctx->targetPath.toString();
|
||||||
@@ -476,7 +476,7 @@ void CustomProjectWizard::initProjectWizardDialog(BaseProjectWizardDialog *w,
|
|||||||
const QList<QWizardPage *> &extensionPages) const
|
const QList<QWizardPage *> &extensionPages) const
|
||||||
{
|
{
|
||||||
const CustomWizardParametersPtr pa = parameters();
|
const CustomWizardParametersPtr pa = parameters();
|
||||||
QTC_ASSERT(!pa.isNull(), return);
|
QTC_ASSERT(pa, return);
|
||||||
|
|
||||||
const CustomWizardContextPtr ctx = context();
|
const CustomWizardContextPtr ctx = context();
|
||||||
ctx->reset();
|
ctx->reset();
|
||||||
|
@@ -7,7 +7,6 @@
|
|||||||
|
|
||||||
#include <coreplugin/basefilewizardfactory.h>
|
#include <coreplugin/basefilewizardfactory.h>
|
||||||
|
|
||||||
#include <QSharedPointer>
|
|
||||||
#include <QList>
|
#include <QList>
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
|
|
||||||
@@ -77,8 +76,8 @@ public:
|
|||||||
static int verbose();
|
static int verbose();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
using CustomWizardParametersPtr = QSharedPointer<Internal::CustomWizardParameters>;
|
using CustomWizardParametersPtr = std::shared_ptr<Internal::CustomWizardParameters>;
|
||||||
using CustomWizardContextPtr = QSharedPointer<Internal::CustomWizardContext>;
|
using CustomWizardContextPtr = std::shared_ptr<Internal::CustomWizardContext>;
|
||||||
|
|
||||||
// generate files in path
|
// generate files in path
|
||||||
Core::GeneratedFiles generateWizardFiles(QString *errorMessage) const;
|
Core::GeneratedFiles generateWizardFiles(QString *errorMessage) const;
|
||||||
|
@@ -63,8 +63,8 @@ CustomWizardFieldPage::PathChooserData::PathChooserData(PathChooser *pe, const Q
|
|||||||
{
|
{
|
||||||
}
|
}
|
||||||
|
|
||||||
CustomWizardFieldPage::CustomWizardFieldPage(const QSharedPointer<CustomWizardContext> &ctx,
|
CustomWizardFieldPage::CustomWizardFieldPage(const std::shared_ptr<CustomWizardContext> &ctx,
|
||||||
const QSharedPointer<CustomWizardParameters> ¶meters,
|
const std::shared_ptr<CustomWizardParameters> ¶meters,
|
||||||
QWidget *parent) :
|
QWidget *parent) :
|
||||||
QWizardPage(parent),
|
QWizardPage(parent),
|
||||||
m_parameters(parameters),
|
m_parameters(parameters),
|
||||||
@@ -376,7 +376,7 @@ bool CustomWizardFieldPage::validatePage()
|
|||||||
}
|
}
|
||||||
|
|
||||||
QMap<QString, QString> CustomWizardFieldPage::replacementMap(const QWizard *w,
|
QMap<QString, QString> CustomWizardFieldPage::replacementMap(const QWizard *w,
|
||||||
const QSharedPointer<CustomWizardContext> &ctx,
|
const std::shared_ptr<CustomWizardContext> &ctx,
|
||||||
const FieldList &f)
|
const FieldList &f)
|
||||||
{
|
{
|
||||||
QMap<QString, QString> fieldReplacementMap = ctx->baseReplacements;
|
QMap<QString, QString> fieldReplacementMap = ctx->baseReplacements;
|
||||||
@@ -402,8 +402,8 @@ QMap<QString, QString> CustomWizardFieldPage::replacementMap(const QWizard *w,
|
|||||||
\sa ProjectExplorer::CustomWizard
|
\sa ProjectExplorer::CustomWizard
|
||||||
*/
|
*/
|
||||||
|
|
||||||
CustomWizardPage::CustomWizardPage(const QSharedPointer<CustomWizardContext> &ctx,
|
CustomWizardPage::CustomWizardPage(const std::shared_ptr<CustomWizardContext> &ctx,
|
||||||
const QSharedPointer<CustomWizardParameters> ¶meters,
|
const std::shared_ptr<CustomWizardParameters> ¶meters,
|
||||||
QWidget *parent) :
|
QWidget *parent) :
|
||||||
CustomWizardFieldPage(ctx, parameters, parent),
|
CustomWizardFieldPage(ctx, parameters, parent),
|
||||||
m_pathChooser(new PathChooser)
|
m_pathChooser(new PathChooser)
|
||||||
|
@@ -8,7 +8,6 @@
|
|||||||
#include <QComboBox>
|
#include <QComboBox>
|
||||||
#include <QCheckBox>
|
#include <QCheckBox>
|
||||||
#include <QWizardPage>
|
#include <QWizardPage>
|
||||||
#include <QSharedPointer>
|
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QFormLayout;
|
class QFormLayout;
|
||||||
@@ -32,8 +31,8 @@ class CustomWizardFieldPage : public QWizardPage {
|
|||||||
public:
|
public:
|
||||||
using FieldList = QList<CustomWizardField>;
|
using FieldList = QList<CustomWizardField>;
|
||||||
|
|
||||||
explicit CustomWizardFieldPage(const QSharedPointer<CustomWizardContext> &ctx,
|
explicit CustomWizardFieldPage(const std::shared_ptr<CustomWizardContext> &ctx,
|
||||||
const QSharedPointer<CustomWizardParameters> ¶meters,
|
const std::shared_ptr<CustomWizardParameters> ¶meters,
|
||||||
QWidget *parent = nullptr);
|
QWidget *parent = nullptr);
|
||||||
|
|
||||||
bool validatePage() override;
|
bool validatePage() override;
|
||||||
@@ -41,7 +40,7 @@ public:
|
|||||||
void cleanupPage() override;
|
void cleanupPage() override;
|
||||||
|
|
||||||
static QMap<QString, QString> replacementMap(const QWizard *w,
|
static QMap<QString, QString> replacementMap(const QWizard *w,
|
||||||
const QSharedPointer<CustomWizardContext> &ctx,
|
const std::shared_ptr<CustomWizardContext> &ctx,
|
||||||
const FieldList &f);
|
const FieldList &f);
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
@@ -85,8 +84,8 @@ private:
|
|||||||
const CustomWizardField &field);
|
const CustomWizardField &field);
|
||||||
void addField(const CustomWizardField &f);
|
void addField(const CustomWizardField &f);
|
||||||
|
|
||||||
const QSharedPointer<CustomWizardParameters> m_parameters;
|
const std::shared_ptr<CustomWizardParameters> m_parameters;
|
||||||
const QSharedPointer<CustomWizardContext> m_context;
|
const std::shared_ptr<CustomWizardContext> m_context;
|
||||||
QFormLayout *m_formLayout;
|
QFormLayout *m_formLayout;
|
||||||
LineEditDataList m_lineEdits;
|
LineEditDataList m_lineEdits;
|
||||||
TextEditDataList m_textEdits;
|
TextEditDataList m_textEdits;
|
||||||
@@ -100,8 +99,8 @@ class CustomWizardPage : public CustomWizardFieldPage
|
|||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
public:
|
public:
|
||||||
explicit CustomWizardPage(const QSharedPointer<CustomWizardContext> &ctx,
|
explicit CustomWizardPage(const std::shared_ptr<CustomWizardContext> &ctx,
|
||||||
const QSharedPointer<CustomWizardParameters> ¶meters,
|
const std::shared_ptr<CustomWizardParameters> ¶meters,
|
||||||
QWidget *parent = nullptr);
|
QWidget *parent = nullptr);
|
||||||
|
|
||||||
Utils::FilePath filePath() const;
|
Utils::FilePath filePath() const;
|
||||||
|
@@ -7,9 +7,8 @@
|
|||||||
|
|
||||||
#include <utils/filepath.h>
|
#include <utils/filepath.h>
|
||||||
|
|
||||||
#include <QStringList>
|
|
||||||
#include <QMap>
|
#include <QMap>
|
||||||
#include <QSharedPointer>
|
#include <QStringList>
|
||||||
|
|
||||||
QT_BEGIN_NAMESPACE
|
QT_BEGIN_NAMESPACE
|
||||||
class QIODevice;
|
class QIODevice;
|
||||||
@@ -117,7 +116,7 @@ public:
|
|||||||
class CustomWizardContext {
|
class CustomWizardContext {
|
||||||
public:
|
public:
|
||||||
using FieldReplacementMap = QMap<QString, QString>;
|
using FieldReplacementMap = QMap<QString, QString>;
|
||||||
using TemporaryFilePtr = QSharedPointer<Utils::TemporaryFile>;
|
using TemporaryFilePtr = std::shared_ptr<Utils::TemporaryFile>;
|
||||||
using TemporaryFilePtrList = QList<TemporaryFilePtr>;
|
using TemporaryFilePtrList = QList<TemporaryFilePtr>;
|
||||||
|
|
||||||
void reset();
|
void reset();
|
||||||
|
@@ -13,7 +13,6 @@
|
|||||||
|
|
||||||
#include <QFileInfo>
|
#include <QFileInfo>
|
||||||
#include <QDebug>
|
#include <QDebug>
|
||||||
#include <QSharedPointer>
|
|
||||||
|
|
||||||
using namespace Utils;
|
using namespace Utils;
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user