forked from qt-creator/qt-creator
Gerrit: 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: I2954186d7e1df0f6e07fa840204f2a4b00fed73e Reviewed-by: Orgad Shaneh <orgads@gmail.com>
This commit is contained in:
@@ -44,8 +44,8 @@ namespace Internal {
|
||||
|
||||
static const int maxTitleWidth = 350;
|
||||
|
||||
GerritDialog::GerritDialog(const QSharedPointer<GerritParameters> &p,
|
||||
const QSharedPointer<GerritServer> &s,
|
||||
GerritDialog::GerritDialog(const std::shared_ptr<GerritParameters> &p,
|
||||
const std::shared_ptr<GerritServer> &s,
|
||||
const FilePath &repository,
|
||||
QWidget *parent)
|
||||
: QDialog(parent)
|
||||
@@ -286,7 +286,7 @@ void GerritDialog::showEvent(QShowEvent *event)
|
||||
void GerritDialog::remoteChanged()
|
||||
{
|
||||
const GerritServer server = m_remoteComboBox->currentServer();
|
||||
if (QSharedPointer<GerritServer> modelServer = m_model->server()) {
|
||||
if (std::shared_ptr<GerritServer> modelServer = m_model->server()) {
|
||||
if (*modelServer == server)
|
||||
return;
|
||||
}
|
||||
@@ -335,7 +335,7 @@ void GerritDialog::slotCurrentChanged()
|
||||
updateButtons();
|
||||
}
|
||||
|
||||
void GerritDialog::fetchStarted(const QSharedPointer<GerritChange> &change)
|
||||
void GerritDialog::fetchStarted(const std::shared_ptr<GerritChange> &change)
|
||||
{
|
||||
// Disable buttons to prevent parallel gerrit operations which can cause mix-ups.
|
||||
m_fetchRunning = true;
|
||||
|
@@ -6,7 +6,6 @@
|
||||
#include <utils/filepath.h>
|
||||
|
||||
#include <QDialog>
|
||||
#include <QSharedPointer>
|
||||
#include <QTimer>
|
||||
|
||||
#include <functional>
|
||||
@@ -40,22 +39,22 @@ class GerritDialog : public QDialog
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
explicit GerritDialog(const QSharedPointer<GerritParameters> &p,
|
||||
const QSharedPointer<GerritServer> &s,
|
||||
explicit GerritDialog(const std::shared_ptr<GerritParameters> &p,
|
||||
const std::shared_ptr<GerritServer> &s,
|
||||
const Utils::FilePath &repository,
|
||||
QWidget *parent = nullptr);
|
||||
~GerritDialog() override;
|
||||
Utils::FilePath repositoryPath() const;
|
||||
void setCurrentPath(const Utils::FilePath &path);
|
||||
void fetchStarted(const QSharedPointer<Gerrit::Internal::GerritChange> &change);
|
||||
void fetchStarted(const std::shared_ptr<Gerrit::Internal::GerritChange> &change);
|
||||
void fetchFinished();
|
||||
void refresh();
|
||||
void scheduleUpdateRemotes();
|
||||
|
||||
signals:
|
||||
void fetchDisplay(const QSharedPointer<Gerrit::Internal::GerritChange> &);
|
||||
void fetchCherryPick(const QSharedPointer<Gerrit::Internal::GerritChange> &);
|
||||
void fetchCheckout(const QSharedPointer<Gerrit::Internal::GerritChange> &);
|
||||
void fetchDisplay(const std::shared_ptr<Gerrit::Internal::GerritChange> &);
|
||||
void fetchCherryPick(const std::shared_ptr<Gerrit::Internal::GerritChange> &);
|
||||
void fetchCheckout(const std::shared_ptr<Gerrit::Internal::GerritChange> &);
|
||||
|
||||
private:
|
||||
void slotCurrentChanged();
|
||||
@@ -76,8 +75,8 @@ private:
|
||||
QPushButton *addActionButton(const QString &text, const std::function<void ()> &buttonSlot);
|
||||
void updateButtons();
|
||||
|
||||
const QSharedPointer<GerritParameters> m_parameters;
|
||||
const QSharedPointer<GerritServer> m_server;
|
||||
const std::shared_ptr<GerritParameters> m_parameters;
|
||||
const std::shared_ptr<GerritServer> m_server;
|
||||
QSortFilterProxyModel *m_filterModel;
|
||||
GerritModel *m_model;
|
||||
QStringListModel *m_queryModel;
|
||||
|
@@ -64,7 +64,7 @@ QDebug operator<<(QDebug d, const GerritChange &c)
|
||||
}
|
||||
|
||||
// Format default Url for a change
|
||||
static inline QString defaultUrl(const QSharedPointer<GerritParameters> &p,
|
||||
static inline QString defaultUrl(const std::shared_ptr<GerritParameters> &p,
|
||||
const GerritServer &server,
|
||||
int gerritNumber)
|
||||
{
|
||||
@@ -208,7 +208,7 @@ class QueryContext : public QObject
|
||||
Q_OBJECT
|
||||
public:
|
||||
QueryContext(const QString &query,
|
||||
const QSharedPointer<GerritParameters> &p,
|
||||
const std::shared_ptr<GerritParameters> &p,
|
||||
const GerritServer &server,
|
||||
QObject *parent = nullptr);
|
||||
|
||||
@@ -236,7 +236,7 @@ private:
|
||||
enum { timeOutMS = 30000 };
|
||||
|
||||
QueryContext::QueryContext(const QString &query,
|
||||
const QSharedPointer<GerritParameters> &p,
|
||||
const std::shared_ptr<GerritParameters> &p,
|
||||
const GerritServer &server,
|
||||
QObject *parent)
|
||||
: QObject(parent)
|
||||
@@ -338,7 +338,7 @@ void QueryContext::timeout()
|
||||
m_timer.start();
|
||||
}
|
||||
|
||||
GerritModel::GerritModel(const QSharedPointer<GerritParameters> &p, QObject *parent)
|
||||
GerritModel::GerritModel(const std::shared_ptr<GerritParameters> &p, QObject *parent)
|
||||
: QStandardItemModel(0, ColumnCount, parent)
|
||||
, m_parameters(p)
|
||||
{
|
||||
@@ -445,7 +445,7 @@ QStandardItem *GerritModel::itemForNumber(int number) const
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void GerritModel::refresh(const QSharedPointer<GerritServer> &server, const QString &query)
|
||||
void GerritModel::refresh(const std::shared_ptr<GerritServer> &server, const QString &query)
|
||||
{
|
||||
if (m_query)
|
||||
m_query->terminate();
|
||||
@@ -731,7 +731,7 @@ static GerritChangePtr parseRestOutput(const QJsonObject &object, const GerritSe
|
||||
return change;
|
||||
}
|
||||
|
||||
static bool parseOutput(const QSharedPointer<GerritParameters> ¶meters,
|
||||
static bool parseOutput(const std::shared_ptr<GerritParameters> ¶meters,
|
||||
const GerritServer &server,
|
||||
const QByteArray &output,
|
||||
QList<GerritChangePtr> &result)
|
||||
|
@@ -7,7 +7,6 @@
|
||||
#include "gerritserver.h"
|
||||
|
||||
#include <QStandardItemModel>
|
||||
#include <QSharedPointer>
|
||||
#include <QDateTime>
|
||||
|
||||
namespace Gerrit {
|
||||
@@ -57,7 +56,7 @@ public:
|
||||
int depth = -1;
|
||||
};
|
||||
|
||||
using GerritChangePtr = QSharedPointer<GerritChange>;
|
||||
using GerritChangePtr = std::shared_ptr<GerritChange>;
|
||||
|
||||
class GerritModel : public QStandardItemModel
|
||||
{
|
||||
@@ -79,7 +78,7 @@ public:
|
||||
GerritChangeRole = Qt::UserRole + 2,
|
||||
SortRole = Qt::UserRole + 3
|
||||
};
|
||||
GerritModel(const QSharedPointer<GerritParameters> &, QObject *parent = nullptr);
|
||||
GerritModel(const std::shared_ptr<GerritParameters> &, QObject *parent = nullptr);
|
||||
~GerritModel() override;
|
||||
|
||||
QVariant data(const QModelIndex &index, int role) const override;
|
||||
@@ -88,12 +87,12 @@ public:
|
||||
QString toHtml(const QModelIndex &index) const;
|
||||
|
||||
QStandardItem *itemForNumber(int number) const;
|
||||
QSharedPointer<GerritServer> server() const { return m_server; }
|
||||
std::shared_ptr<GerritServer> server() const { return m_server; }
|
||||
|
||||
enum QueryState { Idle, Running, Ok, Error };
|
||||
QueryState state() const { return m_state; }
|
||||
|
||||
void refresh(const QSharedPointer<GerritServer> &server, const QString &query);
|
||||
void refresh(const std::shared_ptr<GerritServer> &server, const QString &query);
|
||||
|
||||
signals:
|
||||
void refreshStateChanged(bool isRefreshing); // For disabling the "Refresh" button.
|
||||
@@ -111,13 +110,11 @@ private:
|
||||
const QString &serverPrefix) const;
|
||||
QList<QStandardItem *> changeToRow(const GerritChangePtr &c) const;
|
||||
|
||||
const QSharedPointer<GerritParameters> m_parameters;
|
||||
QSharedPointer<GerritServer> m_server;
|
||||
const std::shared_ptr<GerritParameters> m_parameters;
|
||||
std::shared_ptr<GerritServer> m_server;
|
||||
QueryContext *m_query = nullptr;
|
||||
QueryState m_state = Idle;
|
||||
};
|
||||
|
||||
} // namespace Internal
|
||||
} // namespace Gerrit
|
||||
|
||||
Q_DECLARE_METATYPE(Gerrit::Internal::GerritChangePtr)
|
||||
|
@@ -23,7 +23,7 @@ namespace Gerrit::Internal {
|
||||
class GerritOptionsWidget : public Core::IOptionsPageWidget
|
||||
{
|
||||
public:
|
||||
GerritOptionsWidget(const QSharedPointer<GerritParameters> &p,
|
||||
GerritOptionsWidget(const std::shared_ptr<GerritParameters> &p,
|
||||
const std::function<void()> &onChanged)
|
||||
: m_parameters(p)
|
||||
{
|
||||
@@ -87,12 +87,12 @@ public:
|
||||
}
|
||||
|
||||
private:
|
||||
const QSharedPointer<GerritParameters> &m_parameters;
|
||||
const std::shared_ptr<GerritParameters> &m_parameters;
|
||||
};
|
||||
|
||||
// GerritOptionsPage
|
||||
|
||||
GerritOptionsPage::GerritOptionsPage(const QSharedPointer<GerritParameters> &p,
|
||||
GerritOptionsPage::GerritOptionsPage(const std::shared_ptr<GerritParameters> &p,
|
||||
const std::function<void()> &onChanged)
|
||||
{
|
||||
setId("Gerrit");
|
||||
|
@@ -5,8 +5,6 @@
|
||||
|
||||
#include <coreplugin/dialogs/ioptionspage.h>
|
||||
|
||||
#include <QSharedPointer>
|
||||
|
||||
namespace Gerrit::Internal {
|
||||
|
||||
class GerritParameters;
|
||||
@@ -14,7 +12,7 @@ class GerritParameters;
|
||||
class GerritOptionsPage : public Core::IOptionsPage
|
||||
{
|
||||
public:
|
||||
GerritOptionsPage(const QSharedPointer<GerritParameters> &p,
|
||||
GerritOptionsPage(const std::shared_ptr<GerritParameters> &p,
|
||||
const std::function<void()> &onChanged);
|
||||
};
|
||||
|
||||
|
@@ -60,7 +60,7 @@ class FetchContext : public QObject
|
||||
{
|
||||
Q_OBJECT
|
||||
public:
|
||||
FetchContext(const QSharedPointer<GerritChange> &change,
|
||||
FetchContext(const std::shared_ptr<GerritChange> &change,
|
||||
const FilePath &repository, const FilePath &git,
|
||||
const GerritServer &server,
|
||||
FetchMode fm, QObject *parent = nullptr);
|
||||
@@ -73,7 +73,7 @@ private:
|
||||
void cherryPick();
|
||||
void checkout();
|
||||
|
||||
const QSharedPointer<GerritChange> m_change;
|
||||
const std::shared_ptr<GerritChange> m_change;
|
||||
const FilePath m_repository;
|
||||
const FetchMode m_fetchMode;
|
||||
const Utils::FilePath m_git;
|
||||
@@ -81,7 +81,7 @@ private:
|
||||
Process m_process;
|
||||
};
|
||||
|
||||
FetchContext::FetchContext(const QSharedPointer<GerritChange> &change,
|
||||
FetchContext::FetchContext(const std::shared_ptr<GerritChange> &change,
|
||||
const FilePath &repository, const FilePath &git,
|
||||
const GerritServer &server,
|
||||
FetchMode fm, QObject *parent)
|
||||
@@ -241,11 +241,11 @@ void GerritPlugin::openView()
|
||||
gd->setModal(false);
|
||||
ICore::registerWindow(gd, Context("Git.Gerrit"));
|
||||
connect(gd, &GerritDialog::fetchDisplay, this,
|
||||
[this](const QSharedPointer<GerritChange> &change) { fetch(change, FetchDisplay); });
|
||||
[this](const std::shared_ptr<GerritChange> &change) { fetch(change, FetchDisplay); });
|
||||
connect(gd, &GerritDialog::fetchCherryPick, this,
|
||||
[this](const QSharedPointer<GerritChange> &change) { fetch(change, FetchCherryPick); });
|
||||
[this](const std::shared_ptr<GerritChange> &change) { fetch(change, FetchCherryPick); });
|
||||
connect(gd, &GerritDialog::fetchCheckout, this,
|
||||
[this](const QSharedPointer<GerritChange> &change) { fetch(change, FetchCheckout); });
|
||||
[this](const std::shared_ptr<GerritChange> &change) { fetch(change, FetchCheckout); });
|
||||
connect(this, &GerritPlugin::fetchStarted, gd, &GerritDialog::fetchStarted);
|
||||
connect(this, &GerritPlugin::fetchFinished, gd, &GerritDialog::fetchFinished);
|
||||
m_dialog = gd;
|
||||
@@ -276,7 +276,7 @@ QString GerritPlugin::branch(const FilePath &repository)
|
||||
return gitClient().synchronousCurrentLocalBranch(repository);
|
||||
}
|
||||
|
||||
void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode)
|
||||
void GerritPlugin::fetch(const std::shared_ptr<GerritChange> &change, int mode)
|
||||
{
|
||||
// Locate git.
|
||||
const Utils::FilePath git = gitClient().vcsBinary();
|
||||
@@ -287,7 +287,7 @@ void GerritPlugin::fetch(const QSharedPointer<GerritChange> &change, int mode)
|
||||
|
||||
FilePath repository;
|
||||
bool verifiedRepository = false;
|
||||
if (!m_dialog.isNull() && !m_parameters.isNull() && m_dialog->repositoryPath().exists())
|
||||
if (m_dialog && m_parameters && m_dialog->repositoryPath().exists())
|
||||
repository = m_dialog->repositoryPath();
|
||||
|
||||
if (!repository.isEmpty()) {
|
||||
|
@@ -7,7 +7,6 @@
|
||||
|
||||
#include <QObject>
|
||||
#include <QPointer>
|
||||
#include <QSharedPointer>
|
||||
#include <QPair>
|
||||
|
||||
namespace Core {
|
||||
@@ -45,7 +44,7 @@ public:
|
||||
void updateActions(const VcsBase::VcsBasePluginState &state);
|
||||
|
||||
signals:
|
||||
void fetchStarted(const QSharedPointer<Gerrit::Internal::GerritChange> &change);
|
||||
void fetchStarted(const std::shared_ptr<Gerrit::Internal::GerritChange> &change);
|
||||
void fetchFinished();
|
||||
|
||||
private:
|
||||
@@ -53,10 +52,10 @@ private:
|
||||
void push();
|
||||
|
||||
Utils::FilePath findLocalRepository(const QString &project, const QString &branch) const;
|
||||
void fetch(const QSharedPointer<GerritChange> &change, int mode);
|
||||
void fetch(const std::shared_ptr<GerritChange> &change, int mode);
|
||||
|
||||
QSharedPointer<GerritParameters> m_parameters;
|
||||
QSharedPointer<GerritServer> m_server;
|
||||
std::shared_ptr<GerritParameters> m_parameters;
|
||||
std::shared_ptr<GerritServer> m_server;
|
||||
QPointer<GerritDialog> m_dialog;
|
||||
Core::Command *m_gerritCommand = nullptr;
|
||||
Core::Command *m_pushToGerritCommand = nullptr;
|
||||
|
@@ -106,8 +106,10 @@ void GerritPushDialog::initRemoteBranches()
|
||||
m_remoteComboBox->updateRemotes(false);
|
||||
}
|
||||
|
||||
GerritPushDialog::GerritPushDialog(const Utils::FilePath &workingDir, const QString &reviewerList,
|
||||
QSharedPointer<GerritParameters> parameters, QWidget *parent)
|
||||
GerritPushDialog::GerritPushDialog(const Utils::FilePath &workingDir,
|
||||
const QString &reviewerList,
|
||||
std::shared_ptr<GerritParameters> parameters,
|
||||
QWidget *parent)
|
||||
: QDialog(parent)
|
||||
, m_localBranchComboBox(new BranchComboBox)
|
||||
, m_remoteComboBox(new GerritRemoteChooser)
|
||||
|
@@ -8,7 +8,6 @@
|
||||
#include <QDialog>
|
||||
#include <QMultiMap>
|
||||
#include <QDate>
|
||||
#include <QSharedPointer>
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
class QCheckBox;
|
||||
@@ -33,7 +32,7 @@ class GerritPushDialog : public QDialog
|
||||
|
||||
public:
|
||||
GerritPushDialog(const Utils::FilePath &workingDir, const QString &reviewerList,
|
||||
QSharedPointer<GerritParameters> parameters, QWidget *parent);
|
||||
std::shared_ptr<GerritParameters> parameters, QWidget *parent);
|
||||
|
||||
QString selectedCommit() const;
|
||||
QString selectedRemoteName() const;
|
||||
|
@@ -51,7 +51,7 @@ void GerritRemoteChooser::setRepository(const FilePath &repository)
|
||||
m_repository = repository;
|
||||
}
|
||||
|
||||
void GerritRemoteChooser::setParameters(QSharedPointer<GerritParameters> parameters)
|
||||
void GerritRemoteChooser::setParameters(std::shared_ptr<GerritParameters> parameters)
|
||||
{
|
||||
m_parameters = parameters;
|
||||
}
|
||||
|
@@ -8,7 +8,6 @@
|
||||
#include <utils/filepath.h>
|
||||
|
||||
#include <QComboBox>
|
||||
#include <QSharedPointer>
|
||||
#include <QToolButton>
|
||||
#include <QWidget>
|
||||
|
||||
@@ -26,7 +25,7 @@ class GerritRemoteChooser : public QWidget
|
||||
public:
|
||||
GerritRemoteChooser(QWidget *parent = nullptr);
|
||||
void setRepository(const Utils::FilePath &repository);
|
||||
void setParameters(QSharedPointer<GerritParameters> parameters);
|
||||
void setParameters(std::shared_ptr<GerritParameters> parameters);
|
||||
void setFallbackEnabled(bool value);
|
||||
void setAllowDups(bool value);
|
||||
bool setCurrentRemote(const QString &remoteName);
|
||||
@@ -44,7 +43,7 @@ private:
|
||||
void handleRemoteChanged();
|
||||
|
||||
Utils::FilePath m_repository;
|
||||
QSharedPointer<GerritParameters> m_parameters;
|
||||
std::shared_ptr<GerritParameters> m_parameters;
|
||||
QComboBox *m_remoteComboBox = nullptr;
|
||||
QToolButton *m_resetRemoteButton = nullptr;
|
||||
bool m_updatingRemotes = false;
|
||||
|
Reference in New Issue
Block a user