diff options
Diffstat (limited to 'src/plugins/projectexplorer/devicesupport/devicemanager.cpp')
-rw-r--r-- | src/plugins/projectexplorer/devicesupport/devicemanager.cpp | 25 |
1 files changed, 12 insertions, 13 deletions
diff --git a/src/plugins/projectexplorer/devicesupport/devicemanager.cpp b/src/plugins/projectexplorer/devicesupport/devicemanager.cpp index 585478a611d..e6d78e46517 100644 --- a/src/plugins/projectexplorer/devicesupport/devicemanager.cpp +++ b/src/plugins/projectexplorer/devicesupport/devicemanager.cpp @@ -46,6 +46,7 @@ #include <QVariantList> #include <limits> +#include <memory> namespace ProjectExplorer { namespace Internal { @@ -57,8 +58,7 @@ const char DefaultDevicesKey[] = "DefaultDevices"; class DeviceManagerPrivate { public: - DeviceManagerPrivate() : writer(0) - { } + DeviceManagerPrivate() = default; int indexForId(Core::Id id) const { @@ -74,15 +74,15 @@ public: QHash<Core::Id, Core::Id> defaultDevices; QSsh::SshHostKeyDatabasePtr hostKeyDatabase; - Utils::PersistentSettingsWriter *writer; + Utils::PersistentSettingsWriter *writer = nullptr; }; -DeviceManager *DeviceManagerPrivate::clonedInstance = 0; +DeviceManager *DeviceManagerPrivate::clonedInstance = nullptr; } // namespace Internal using namespace Internal; -DeviceManager *DeviceManager::m_instance = 0; +DeviceManager *DeviceManager::m_instance = nullptr; DeviceManager *DeviceManager::instance() { @@ -104,12 +104,12 @@ void DeviceManager::replaceInstance() void DeviceManager::removeClonedInstance() { delete DeviceManagerPrivate::clonedInstance; - DeviceManagerPrivate::clonedInstance = 0; + DeviceManagerPrivate::clonedInstance = nullptr; } DeviceManager *DeviceManager::cloneInstance() { - QTC_ASSERT(!DeviceManagerPrivate::clonedInstance, return 0); + QTC_ASSERT(!DeviceManagerPrivate::clonedInstance, return nullptr); DeviceManagerPrivate::clonedInstance = new DeviceManager(false); copy(instance(), DeviceManagerPrivate::clonedInstance, true); @@ -210,7 +210,7 @@ QVariantMap DeviceManager::toMap() const { QVariantMap map; QVariantMap defaultDeviceMap; - typedef QHash<Core::Id, Core::Id> TypeIdHash; + using TypeIdHash = QHash<Core::Id, Core::Id>; for (TypeIdHash::ConstIterator it = d->defaultDevices.constBegin(); it != d->defaultDevices.constEnd(); ++it) { defaultDeviceMap.insert(it.key().toString(), it.value().toSetting()); @@ -349,7 +349,7 @@ const IDeviceFactory *DeviceManager::restoreFactory(const QVariantMap &map) return factory; } -DeviceManager::DeviceManager(bool isInstance) : d(new DeviceManagerPrivate) +DeviceManager::DeviceManager(bool isInstance) : d(std::make_unique<DeviceManagerPrivate>()) { if (isInstance) { QTC_ASSERT(!m_instance, return); @@ -370,8 +370,7 @@ DeviceManager::~DeviceManager() if (d->clonedInstance != this) delete d->writer; if (m_instance == this) - m_instance = 0; - delete d; + m_instance = nullptr; } IDevice::ConstPtr DeviceManager::deviceAt(int idx) const @@ -429,9 +428,9 @@ public: static Core::Id testTypeId() { return "TestType"; } private: - TestDevice(const TestDevice &other) : IDevice(other) {} + TestDevice(const TestDevice &other) = default; QString displayType() const override { return QLatin1String("blubb"); } - IDeviceWidget *createWidget() override { return 0; } + IDeviceWidget *createWidget() override { return nullptr; } QList<Core::Id> actionIds() const override { return QList<Core::Id>(); } QString displayNameForActionId(Core::Id) const override { return QString(); } void executeAction(Core::Id, QWidget *) override { } |