View Full Version : COFFEE | Remove() Tag and crash on quit, help
06-28-2006, 09:09 PM
I've spent many hours to solve this and are at loss.
What is the correct way to Remove() a coffe expression pluginTag?
What is happening is I remove the Tag by a UserData on the tag itself.
That works fine as long as I'm working in the scene. I can Undo etc.
However, when I finaly quit Cinema , it crashes.
Looking thru the boards (PluginCafe) I find the Free() option. But only together with C++. Can't find it in the Coffe SDK.
I've tried using Free() in COFFE but have failed to get it working.
As well as all sorts of AddEvents, force redraw, MSG_UPDATE etc
I also found an answer that if the tag have a tag check running,
if [tag->GetType() == type).....etc
it might not be wise to Remove it. But I need to do that :)
What I suspect is that I can't get the Tag free from the document.
Any ideas what to check/do/try?
06-29-2006, 10:49 PM
You can't kill an object from within itself (after all how can it finish the call if the function that's calling it no longer exists). So you need to use another tag/object to do this, also you will need to use the remove command. I can't remember if there is a delete for tags/objects in coffee or if it's garbage collection handles that for you.
06-29-2006, 11:06 PM
Hi Per Anders.
Yup I'm looking into gc() atm. SDK says coffee handles gc by itself but have a note that it could be used.
The thing is , I have it working:) Both when putting the code into a regular COFFEE tag and running it as a Tag plugin. The only difference is that when used in a regular COFFE tag, Cinema doesnt crash when I quit. So I suspect Cinema have a way to correct stuff automatically. Just need to find how to apply that same clean up myself...
I'm about to cleanup/minimize the code for further checking and possible posting(thats when I found out that dialoges doesn't open in a COFFEE tag using the same code, see other post).
06-30-2006, 02:09 AM
This is the deal.
First taking all other plugins out, no difference.
And here it comes....this was running PPC.
Running UB it - does - not - happen!! With or without other plugins.
Close to a bug as it looks.
Will contact Maxon tomorrow, it's 3am by now and I'm dead..
07-05-2006, 06:26 PM
Close to a bug as it looks.Could be. It could also just be that the difference in the way the two C++ compilers handle the heap causes a different side effect when you corrupt it. Point being, the UB version could break mysteriously at some later time. Best get in touch with MAXON and see if they can give you a solid fix.
07-05-2006, 06:44 PM
As of now , and what I've got from Maxon, UB is ok running CoffeePlugin(.cof) and COFFEE Tag, PPC only COFFEE Tag is ok, PC it is reversed. COFFEE Tag dives and CoffeePlugin runs with no problem. (There is no C++ involved at all)
07-07-2006, 05:45 AM
I've done some tests, both Windows and MacOS, for Lennart here. The fact that a tag removes itself from a list should not be a crash situation - the code that it needs is still viable (um, when does the deconstructor become invalid because the object isn't in a list? gc() - explicit or implicit - takes the deconstructor into account one hopes.). The tag is still in memory and has most functionality. This is definitely a COFFEE bug - as can be seen by the behavior on both systems being different (one works one way, the other works the other).
On the other hand, I think that the fact that it removes itself within Execute() may have a bearing on cleanup during this process. COFFEE doesn't have the code options for tags that the C++ SDK has (doesn't need to be an Expression tag, for instance). Removal at this point - although required - may 'surprise' the COFFEE system in these limited situations.
07-07-2006, 07:00 PM
There is no C++ involved at allI understand why you think this, but you should not assume that the COFFEE interpreter behaves 100% identically in the two versions of C4D. All aspects of the language that are specified in the SDK documentation should behave as documented, but there is an awful lot that is not documented. The parts that are not documented could indeed vary depending on what compiler built the COFFEE interpreter.
For instance, if you release an object and then allocate a new one, will the new object always occupy space that used to belong to the other one, or will it come from somewhere else? Is it even determinate? Those sorts of differences could make a difference in a situation like yours. The COFFEE interpreter would have to take exquisite care to do memory management exactly the same way regardless of platform to avoid differences here.
07-07-2006, 07:00 PM
This thread has been automatically closed as it remained inactive for 12 months. If you wish to continue the discussion, please create a new thread in the appropriate forum.
vBulletin v3.0.5, Copyright ©2000-2015, Jelsoft Enterprises Ltd.