qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: [PATCH 2/2] qom: Assert that objects being destroyed have no parent


From: Paolo Bonzini
Subject: Re: [PATCH 2/2] qom: Assert that objects being destroyed have no parent
Date: Wed, 16 Dec 2020 14:31:54 +0100
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.4.0

On 16/12/20 08:53, Marc-André Lureau wrote:

On the principle, I fully agree. But the risk is high to introduce regression if objects are manipulated in strange ways.

I remember I wanted object_unref() to automatically remove itself from the parent when the last ref is dropped. I think there were similar concerns.

unref and unparent are two very different operations; the former means *I* am done with this object, the latter means *QEMU* is done with this object (even though there may be a few reference held, e.g. on the call stack or by RCU). Since object_unparent operates on global state, you can even call object_unparent if you don't own yourself a reference to the object and just got the pointer from the caller.

While unref is a "mechanical" operation of dropping a reference and possibly freeing the object, unparent is an active operation that includes for example dropping reference cycles or in general detaching from other places that are known to hold references to this object.

This is not a concept that is specific to QEMU, I think I read somewhere that LibreOffice's UI library does something similar, calling it "dispose".

Paolo




reply via email to

[Prev in Thread] Current Thread [Next in Thread]