Commit ad691a62 authored by David Edmundson's avatar David Edmundson Committed by Nate Graham
Browse files

Avoid combining smart pointers and qobject parent ownership

Devices are stored as QSharedPointer<Device> mDevices. If something has
the memory managed explicitly we don't want QObject parents to also try
and do the same job.

BUG: 439192

(cherry picked from commit 09c37c1c)
parent e761487c
Pipeline #238077 passed with stage
in 1 minute and 33 seconds
......@@ -45,10 +45,10 @@ Device::Device(const QDBusObjectPath &path, QObject *parent)
Device::~Device() = default;
QSharedPointer<Device> Device::create(const QDBusObjectPath &path, QObject *parent)
QSharedPointer<Device> Device::create(const QDBusObjectPath &path)
try {
return QSharedPointer<Device>::create(path, parent);
return QSharedPointer<Device>::create(path);
} catch (const DBusException &e) {
qCWarning(log_libkbolt, "%s", e.what());
return {};
......@@ -46,7 +46,7 @@ class KBOLT_EXPORT Device : public QObject, public QEnableSharedFromThis<Device>
friend class Manager;
static QSharedPointer<Device> create(const QDBusObjectPath &path, QObject *parent = nullptr);
static QSharedPointer<Device> create(const QDBusObjectPath &path);
explicit Device(QObject *parent = nullptr);
~Device() override;
......@@ -26,7 +26,7 @@ Manager::Manager(QObject *parent)
connect(mInterface.get(), &ManagerInterface::DeviceAdded, this, [this](const QDBusObjectPath &path) {
if (auto device = Device::create(path, this)) {
if (auto device = Device::create(path)) {
"New Thunderbolt device %s (%s) added, status=%s",
......@@ -46,7 +46,7 @@ Manager::Manager(QObject *parent)
const auto devicePaths = mInterface->ListDevices().argumentAt<0>();
for (const auto &devicePath : devicePaths) {
if (auto device = Device::create(devicePath, this)) {
if (auto device = Device::create(devicePath)) {
"Discovered Thunderbolt device %s (%s), status=%s",
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment