IsAlive() Problem + Workaround



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 24/02/2011 at 14:20, xxxxxxxx wrote:

    Hi,

    if one wants to acess an object using Userdata an the referenceobject becomes removed, the link to the object still exists. If this is not as it ia supposed to be, see it as kind of a Bugreport. ;)

    I had a few problems then, because the Object didn't exist in the document, but it's still in the Userdata.
    Even the BaseList2D.IsAlive() method did not help, it returned True always.

    But i could find a Workaround:

    def IsAlive(op) :   
        if not op.GetDocument() : return False   
        return True   
    

    Cheers, nux



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 24/02/2011 at 15:50, xxxxxxxx wrote:

    Yeah.
    It's kind of a long standing issue in C4D.

    The most common way I see people dealing with it in regards to UserData. Is to add a null to the link field after the previously refrenced object was removed. Then removing the null.
    Kind of clumsy. But it works.

    I'd be surprised if the developers don't already know about this.

    -ScottA



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 24/02/2011 at 18:23, xxxxxxxx wrote:

    @nux95: This is a known bug and will be fixed with the next update. To keep your plugins downwards compatible, you should add a check if op is None (which will be the case after the update).

    Some background information about the exception that an object is not alive anymore:
    If you have a reference to an object(BaseObject, BaseTag) in your plugin and the user or C4D deletes
    it, the reference becomes invalid and raises an exception. The reference is still alive but the established object is already freed.


Log in to reply