THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED
On 16/02/2006 at 03:03, xxxxxxxx wrote:
Cinema 4D Version: 9.52
Platform: Windows ; Mac ; Mac OSX ;
Language(s) : C++ ;
BaseObject *op = GetActiveDocument()->GetActiveObject();
if (op->GetInfo() & OBJECT_ISSPLINE) // GetInfo .... here CRASH
That's too simple ... but crashed C4D. Can I make any wrong ?
On 16/02/2006 at 06:32, xxxxxxxx wrote:
How about this:
if (doc = GetActiveDocument())
BaseObject* op = doc->GetActiveObject();
if (op && (op->GetInfo() & OBJECT_ISSPLINE))
It is possible that there is no object in the document (yet) and the return is NULL. It is also possible that there is no document yet if the dialog is being loaded during Cinema 4D startup - i.e.: has been docked in the Startup Layout and you are using RestoreLayout(). In this case, you may need to do this in GeDialog::CoreMessage() on the appropriate message.
Always check your pointers!
On 17/02/2006 at 01:52, xxxxxxxx wrote:
kuroyume0161 = Robert = genius
Infact, there aren't yet ready objects in document ... (for this, C4D crash).
mmmm... do you mean GeDialog::CoreMessage() on the appropriate message ?
and... with your experience, you think that the Maxon will repair (or avoid) the C4D crashes when any developper forget any initializiation ? Becouse if crashed, how is possible debuggin ? If the plugin is simple (with few source code) a programmer normally find the problem(s)... instead if the plugin is difficult (and a lot of code, pointers, classes, data, dialogs, descriptions, strings...) and C4D crashed.... a poor programmer lost great time to resolve that.
Anymore, thx kuro.
On 17/02/2006 at 09:55, xxxxxxxx wrote:
GeDialog::Message() only receives messages specificly for the dialog. GeDialog::CoreMessage() will receive more generic messages from Cinema 4D. Best to check which messages are sent, but EVMSG_CHANGE might be worth checking for. Whenever I need to know if some sort of message is being received in a particular situation, I use GePrint() from the either of these methods to see what it might be.
Or, you may need to set up a timer and check the available document(s) periodically. I normally don't tie my dialogs to documents and objects except through user-interaction.
Causes for Cinema 4D startup plugin crashes are diabolically difficult to track down. As you note, you really can't debug, not even to the Console Window or a command line. The best course of action in such situations is to go to the top levels of your plugin code, comment out as much as possible, and add lines or sections back in one at a time while compiling and testing.
Not much for Maxon to do about this. Since plugins are static libraries, they have no control over the execution of the code other than executing it.