forked from qt-creator/qt-creator
CorePlugin: 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: Id64f1033ed0a640bb3f02821b3b5f99c7fa3987d Reviewed-by: <github-actions-qt-creator@cristianadam.eu> Reviewed-by: hjk <hjk@qt.io>
This commit is contained in:
@@ -322,7 +322,7 @@ void ExternalToolModel::revertTool(const QModelIndex &modelIndex)
|
|||||||
ExternalTool *tool = toolForIndex(modelIndex);
|
ExternalTool *tool = toolForIndex(modelIndex);
|
||||||
QTC_ASSERT(tool, return);
|
QTC_ASSERT(tool, return);
|
||||||
QTC_ASSERT(tool->preset() && !tool->preset()->filePath().isEmpty(), return);
|
QTC_ASSERT(tool->preset() && !tool->preset()->filePath().isEmpty(), return);
|
||||||
auto resetTool = new ExternalTool(tool->preset().data());
|
auto resetTool = new ExternalTool(tool->preset().get());
|
||||||
resetTool->setPreset(tool->preset());
|
resetTool->setPreset(tool->preset());
|
||||||
(*tool) = (*resetTool);
|
(*tool) = (*resetTool);
|
||||||
delete resetTool;
|
delete resetTool;
|
||||||
|
@@ -190,7 +190,7 @@ void ExternalTool::setFilePath(const FilePath &filePath)
|
|||||||
m_filePath = filePath;
|
m_filePath = filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
void ExternalTool::setPreset(QSharedPointer<ExternalTool> preset)
|
void ExternalTool::setPreset(std::shared_ptr<ExternalTool> preset)
|
||||||
{
|
{
|
||||||
m_presetTool = preset;
|
m_presetTool = preset;
|
||||||
}
|
}
|
||||||
@@ -200,7 +200,7 @@ FilePath ExternalTool::filePath() const
|
|||||||
return m_filePath;
|
return m_filePath;
|
||||||
}
|
}
|
||||||
|
|
||||||
QSharedPointer<ExternalTool> ExternalTool::preset() const
|
std::shared_ptr<ExternalTool> ExternalTool::preset() const
|
||||||
{
|
{
|
||||||
return m_presetTool;
|
return m_presetTool;
|
||||||
}
|
}
|
||||||
|
@@ -10,7 +10,6 @@
|
|||||||
#include <utils/id.h>
|
#include <utils/id.h>
|
||||||
|
|
||||||
#include <QObject>
|
#include <QObject>
|
||||||
#include <QSharedPointer>
|
|
||||||
#include <QTextCodec>
|
#include <QTextCodec>
|
||||||
#include <QMetaType>
|
#include <QMetaType>
|
||||||
|
|
||||||
@@ -51,10 +50,10 @@ public:
|
|||||||
Utils::EnvironmentItems environmentUserChanges() const;
|
Utils::EnvironmentItems environmentUserChanges() const;
|
||||||
|
|
||||||
void setFilePath(const Utils::FilePath &filePath);
|
void setFilePath(const Utils::FilePath &filePath);
|
||||||
void setPreset(QSharedPointer<ExternalTool> preset);
|
void setPreset(std::shared_ptr<ExternalTool> preset);
|
||||||
Utils::FilePath filePath() const;
|
Utils::FilePath filePath() const;
|
||||||
// all tools that are preset (changed or unchanged) have the original value here:
|
// all tools that are preset (changed or unchanged) have the original value here:
|
||||||
QSharedPointer<ExternalTool> preset() const;
|
std::shared_ptr<ExternalTool> preset() const;
|
||||||
|
|
||||||
static ExternalTool *createFromXml(const QByteArray &xml, QString *errorMessage = nullptr,
|
static ExternalTool *createFromXml(const QByteArray &xml, QString *errorMessage = nullptr,
|
||||||
const QString &locale = {});
|
const QString &locale = {});
|
||||||
@@ -99,7 +98,7 @@ private:
|
|||||||
|
|
||||||
Utils::FilePath m_filePath;
|
Utils::FilePath m_filePath;
|
||||||
Utils::FilePath m_presetFileName;
|
Utils::FilePath m_presetFileName;
|
||||||
QSharedPointer<ExternalTool> m_presetTool;
|
std::shared_ptr<ExternalTool> m_presetTool;
|
||||||
};
|
};
|
||||||
|
|
||||||
class CORE_EXPORT ExternalToolRunner : public QObject
|
class CORE_EXPORT ExternalToolRunner : public QObject
|
||||||
|
@@ -6,7 +6,6 @@
|
|||||||
#include "externaltool.h"
|
#include "externaltool.h"
|
||||||
#include "coreconstants.h"
|
#include "coreconstants.h"
|
||||||
#include "coreplugintr.h"
|
#include "coreplugintr.h"
|
||||||
#include "icontext.h"
|
|
||||||
#include "icore.h"
|
#include "icore.h"
|
||||||
#include "messagemanager.h"
|
#include "messagemanager.h"
|
||||||
#include "actionmanager/actionmanager.h"
|
#include "actionmanager/actionmanager.h"
|
||||||
@@ -114,7 +113,7 @@ void ExternalToolManager::parseDirectory(const QString &directory,
|
|||||||
if (isPreset) {
|
if (isPreset) {
|
||||||
// preset that was changed
|
// preset that was changed
|
||||||
ExternalTool *other = tools->value(tool->id());
|
ExternalTool *other = tools->value(tool->id());
|
||||||
other->setPreset(QSharedPointer<ExternalTool>(tool));
|
other->setPreset(std::shared_ptr<ExternalTool>(tool));
|
||||||
} else {
|
} else {
|
||||||
qWarning() << Tr::tr("Error: External tool in %1 has duplicate id").arg(fileName);
|
qWarning() << Tr::tr("Error: External tool in %1 has duplicate id").arg(fileName);
|
||||||
delete tool;
|
delete tool;
|
||||||
@@ -123,7 +122,7 @@ void ExternalToolManager::parseDirectory(const QString &directory,
|
|||||||
}
|
}
|
||||||
if (isPreset) {
|
if (isPreset) {
|
||||||
// preset that wasn't changed --> save original values
|
// preset that wasn't changed --> save original values
|
||||||
tool->setPreset(QSharedPointer<ExternalTool>(new ExternalTool(tool)));
|
tool->setPreset(std::shared_ptr<ExternalTool>(new ExternalTool(tool)));
|
||||||
}
|
}
|
||||||
tools->insert(tool->id(), tool);
|
tools->insert(tool->id(), tool);
|
||||||
(*categoryMenus)[tool->displayCategory()].insert(tool->order(), tool);
|
(*categoryMenus)[tool->displayCategory()].insert(tool->order(), tool);
|
||||||
|
Reference in New Issue
Block a user