[Kde-hardware-devel] Solid DevicePrivate object ownership
Jiří Paleček
jpalecek at web.de
Thu Nov 5 11:49:36 CET 2009
Hello,
I've been hunting some memeory leaks in plasma and it seems to me the
culprit was the solid library. But to understand the matter fully, I need
clarifications on the following questions:
1) A DevicePrivate for a specific device exists at most once in the
program, and is always cached in the DeviceManager, is that right?
2) By whom is the m_backendObject of the DevicePrivate owned (and should
be deleted)?
3)
void Solid::DevicePrivate::setInterface(const DeviceInterface::Type &type,
DeviceInterface *interface)
{
ref.ref();
m_ifaces[type] = interface;
}
Why is the reference count raised every time we add an interface?
4)
void Solid::DevicePrivate::setBackendObject(Ifaces::Device *object)
{
m_backendObject = object;
if (m_backendObject) {
connect(m_backendObject, SIGNAL(destroyed(QObject *)),
this, SLOT(_k_destroyed(QObject *)));
}
if (!m_ifaces.isEmpty()) {
foreach (DeviceInterface *iface, m_ifaces) {
delete iface->d_ptr->backendObject();
delete iface;
}
m_ifaces.clear();
if (!ref.deref()) deleteLater();
}
}
And why is it decreased once we reset the backend object?
5)
void Solid::DevicePrivate::setBackendObject(Ifaces::Device *object)
{
...
foreach (DeviceInterface *iface, m_ifaces) {
delete iface->d_ptr->backendObject();
delete iface;
}
Why do we delete iface->d_ptr->backendObject() here ...
Solid::DevicePrivate::~DevicePrivate()
{
qDeleteAll(m_ifaces);
}
... and not here?
Regards
Jiri Palecek
--
Using Opera's revolutionary e-mail client: http://www.opera.com/mail/
More information about the Kde-hardware-devel
mailing list