[patch] slightly controversial refactor
Jeff Mitchell
kde-dev at emailgoeshere.com
Sat Jan 20 19:04:32 UTC 2007
On Saturday 20 January 2007 10:31, Jeff Mitchell wrote:
> The onus isn't really on the caller to delete the returned object; we want
> that object to stay valid in m_mediumMap, unless it's refreshed by some
> mechanism (as in getDevice). So really what should happen is that in the
> DeviceManager's destructor code, all objects in m_mediumMap should be
> deleted. But that's the only memory leak going on, and it's not a hugely
> important one as the DeviceManager is never deleted until Amarok exits.
> Fixing that would be more of a completeness exercise than anything else but
> should probably be done.
What do you know, there was a memory leak after all.
After applying Erik's patch and updating the DeviceManager destructor, I found
that reality didn't actually match what I thought was going on in theory.
Two new Medium objects were being created in getDevice instead of two
pointers both being assigned to a single one. Seems this has always been the
way, even before Erik's patch and before his previous SVN commit. :-| I
didn't catch it when going through the getDevice code when composing my
previous reply.
Anyways, this has been fixed. I don't expect it to cause problems as no
client code should be deleting that returned Medium, and my grep/looksee
through client code that uses getDevice seemed to indicate that this is true.
--Jeff
More information about the Amarok
mailing list