diff --git a/src/core/device.cpp b/src/core/device.cpp index 2db86df..b52177c 100644 --- a/src/core/device.cpp +++ b/src/core/device.cpp @@ -44,7 +44,7 @@ Device::Device(const QString& name, d->m_TotalLogical = totalLogicalSectors; d->m_PartitionTable = nullptr; d->m_IconName = iconName.isEmpty() ? QStringLiteral("drive-harddisk") : iconName; - d->m_SmartStatus = type == Device::Disk_Device ? new SmartStatus(deviceNode) : nullptr; + d->m_SmartStatus = type == Device::Disk_Device ? std::make_shared(deviceNode) : nullptr; d->m_Type = type; } @@ -62,11 +62,10 @@ Device::Device(const Device& other) d->m_IconName = other.d->m_IconName; d->m_SmartStatus = nullptr; d->m_Type = other.d->m_Type; + d->m_SmartStatus = other.d->m_SmartStatus; if (other.d->m_PartitionTable) d->m_PartitionTable = new PartitionTable(*other.d->m_PartitionTable); - if (other.d->m_SmartStatus) - d->m_SmartStatus = new SmartStatus(*other.d->m_SmartStatus); } /** Destructs a Device. */ diff --git a/src/core/device_p.h b/src/core/device_p.h index 5ddab62..0577fe3 100644 --- a/src/core/device_p.h +++ b/src/core/device_p.h @@ -19,6 +19,8 @@ #include +#include + class PartitionTable; class SmartStatus; @@ -30,6 +32,6 @@ struct DevicePrivate qint64 m_TotalLogical; PartitionTable* m_PartitionTable; QString m_IconName; - SmartStatus* m_SmartStatus; + std::shared_ptr m_SmartStatus; Device::Type m_Type; }; diff --git a/src/core/smartstatus.h b/src/core/smartstatus.h index d064b7e..88b410d 100644 --- a/src/core/smartstatus.h +++ b/src/core/smartstatus.h @@ -121,7 +121,7 @@ public: static QString overallAssessmentToString(Overall o); static QString selfTestStatusToString(SmartStatus::SelfTestStatus s); -protected: +private: void setStatus(bool s) { m_Status = s;