merkvilson last edited by merkvilson
Hello PluginCafe :)
I tried to insert a cache of selected object into the doc via Console but I got this error/crash.
is it possible to bypass this behavior?
s_bach last edited by
this is no bug of the Python API. The code is just unsafe.
BaseObject(generator) owns the content of its cache. This cache may be a
BaseObject(and subsequent child objects) or nothing -
So if you operate with a cache you should always check if that cache is actually set.
GetCache()can always return
cache = op.GetCache() if cache is None: return
But the real problem is that the given
BaseObjectowns the content of the cache. In your code, you take the cache and inset it into the
BaseDocument. Both the generator and the
BaseObjectnow think they do have sole ownership of the cache content. This can't work and is a perfect recipe for any kind of undefined behaviour - including a crash.
So you cannot insert the cache into the
BaseDocument. You must create a copy of the cache (
GetClone()) and insert that copy into the
merkvilson last edited by
Thanks, Sebastian for detailed explanation :)
But this still can be considered as a bug since it CRASHES c4d instead of raising an error message.
m_adam last edited by
Hi @merkvilson, this feedback has been communicated to our development team.