Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush Python API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Recent
    • Tags
    • Users
    • Login

    Render Crash

    Scheduled Pinned Locked Moved SDK Help
    15 Posts 0 Posters 1.1k Views
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • H Offline
      Helper
      last edited by

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

      On 29/12/2009 at 07:34, xxxxxxxx wrote:

      In general yes, GetActiveDocument() should not be used in a render or object creation context. Usally you get a valid document passed to these sensitive functions. Where are you using GetActiveDocument()?

      Btw. what kind of plugin are we talking about, an object, tag, shader etc?

      cheers,
      Matthias

      1 Reply Last reply Reply Quote 0
      • H Offline
        Helper
        last edited by

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

        On 29/12/2009 at 07:36, xxxxxxxx wrote:

        an object plugin.

        I searched through the code and I do not use GetActiveDocument()..   I use GetDocument()   but never GetActiveDocument()..    I do use GetActiveObject()...

        would GetActiveObject cause the same problem?

        1 Reply Last reply Reply Quote 0
        • H Offline
          Helper
          last edited by

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

          On 29/12/2009 at 07:53, xxxxxxxx wrote:

          Originally posted by xxxxxxxx

          would GetActiveObject cause the same problem?

          Probably. It does sound kinda strange to me to use GetActiveObject() in an object plugin. In which context are you using this function? Anyway as long as you always check for NULL pointers and react accordingly it should not crash. But there can be alot of reasons why your plugin is crashing.

          cheers,
          Matthias

          1 Reply Last reply Reply Quote 0
          • H Offline
            Helper
            last edited by

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

            On 29/12/2009 at 08:02, xxxxxxxx wrote:

            I use GetActiveObject like this

            BaseObject* prnt = doc->GetActiveObject();

            then whenever I need to find objects that are the children of my object I use....

            prnt->GetDown()-GetNext()   etc.....

            It is possible that I have not checked for a NULL pointer somewhere...    I will look around and use some GePrint() to see what is causing the crash.

            ~Shawn

            1 Reply Last reply Reply Quote 0
            • H Offline
              Helper
              last edited by

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

              On 29/12/2009 at 08:14, xxxxxxxx wrote:

              I have determined that the crash is happening here:   Do you see anything that should be different?

                
                
              void Planet::Free(GeListNode* node)  
              {  
                GePrint("FREE");      
                BaseObject* op = static_cast<BaseTag*>(node)->GetObject();  
                    if (!op) goto BYPASS;  
                
                BaseObject* prnt = op->GetDocument()->GetActiveObject();  
                    if (!prnt) goto BYPASS;  
                
                    //Remove Materials when Object is deleted  
                    if (prnt->GetDown())  
                    {  
                        TextureTag* surfaceTag = (TextureTag* )(prnt->GetDown()->GetFirstTag());  
                        TextureTag* lightTag = (TextureTag* )(prnt->GetDown()->GetFirstTag()->GetNext());  
                        TextureTag* cloudTag = (TextureTag* )(prnt->GetDown()->GetNext()->GetFirstTag());  
                        TextureTag* atmTag = (TextureTag* )(prnt->GetDown()->GetNext()->GetNext()->GetFirstTag());  
                      
                        surfaceTag->GetMaterial()->Remove();  
                        lightTag->GetMaterial()->Remove();  
                        cloudTag->GetMaterial()->Remove();  
                        atmTag->GetMaterial()->Remove();  
                    }  
              BYPASS:;  
                
              }  
                
              
              1 Reply Last reply Reply Quote 0
              • H Offline
                Helper
                last edited by

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

                On 29/12/2009 at 09:29, xxxxxxxx wrote:

                yes, you must free all the materials that you have removed. You should check the docs more carefully.

                _<_h4_>_void Remove(v_<_h4_>_/h4>
                Remove this node from its list.

                Note: When you remove a node you become responsible for freeing it, or passing the ownership to another list by inserting it there.

                Furthermore you should check the pointers returned by GetDown() etc. if one of these is NULL, it´ll crash. ALWAYS check your pointers.

                1 Reply Last reply Reply Quote 0
                • H Offline
                  Helper
                  last edited by

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

                  On 29/12/2009 at 10:31, xxxxxxxx wrote:

                  Would I free them like this?

                    
                    
                  void Planet::Free(GeListNode* node)  
                  {  
                    GePrint("FREE");      
                    GePrint("1");  
                    BaseObject* op = static_cast<BaseTag*>(node)->GetObject();  
                        if (!op) goto BYPASS;  
                  GePrint("2");  
                    BaseObject* prnt = op->GetDocument()->GetActiveObject();  
                        if (!prnt) goto BYPASS;  
                  GePrint("3");  
                        //Remove Materials when Object is deleted  
                        if (prnt->GetDown())  
                        {  
                            GePrint("4");  
                            TextureTag* surfaceTag = (TextureTag* )(prnt->GetDown()->GetFirstTag());  
                            TextureTag* lightTag = (TextureTag* )(prnt->GetDown()->GetFirstTag()->GetNext());  
                            TextureTag* cloudTag = (TextureTag* )(prnt->GetDown()->GetNext()->GetFirstTag());  
                            TextureTag* atmTag = (TextureTag* )(prnt->GetDown()->GetNext()->GetNext()->GetFirstTag());  
                              
                            GePrint("4.1");  
                            surfaceTag->GetMaterial()->Remove();  
                            lightTag->GetMaterial()->Remove();  
                            cloudTag->GetMaterial()->Remove();  
                            atmTag->GetMaterial()->Remove();  
                    
                            GePrint("4.2");  
                    
                            Free(surfaceTag->GetMaterial());  
                            Free(lightTag->GetMaterial());  
                            Free(cloudTag->GetMaterial());  
                            Free(atmTag->GetMaterial());  
                    
                            GePrint("4.3");  
                    
                        }  
                  BYPASS:;  
                  GePrint("5");  
                  }  
                    
                  

                  sorry about all the GePrint()..    they are for my own debugging purposes.

                  ~Shawn

                  1 Reply Last reply Reply Quote 0
                  • H Offline
                    Helper
                    last edited by

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

                    On 29/12/2009 at 10:33, xxxxxxxx wrote:

                    that code I just sent crashes after GePrint("4.2");

                    1 Reply Last reply Reply Quote 0
                    • H Offline
                      Helper
                      last edited by

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

                      On 29/12/2009 at 10:47, xxxxxxxx wrote:

                      if you remove then surfaceTag->GetMaterial() will be NULL as it is not in the scene anymore.

                      do it like this:

                      BaseMaterial\* mat1 = surfaceTag->GetMaterial();  
                      mat1->Remove();  
                      BaseMaterial::Free(mat1);
                      
                      1 Reply Last reply Reply Quote 0
                      • H Offline
                        Helper
                        last edited by

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

                        On 29/12/2009 at 10:59, xxxxxxxx wrote:

                        Okay it works great for deleting the object..,..    but when I try to render using the picture viewer,  it crashes at 4.1    here's the code I am using now.

                          
                        void Planet::Free(GeListNode* node)  
                        {  
                          GePrint("FREE");      
                          GePrint("1");  
                          BaseObject* op = static_cast<BaseTag*>(node)->GetObject();  
                              if (!op) goto BYPASS;  
                        GePrint("2");  
                          BaseObject* prnt = op->GetDocument()->GetActiveObject();  
                              if (!prnt) goto BYPASS;  
                        GePrint("3");  
                              //Remove Materials when Object is deleted  
                              if (prnt->GetDown())  
                              {  
                                    
                                  GePrint("4");  
                                  TextureTag* surfaceTag = (TextureTag* )(prnt->GetDown()->GetFirstTag());  
                                  TextureTag* lightTag = (TextureTag* )(prnt->GetDown()->GetFirstTag()->GetNext());  
                                  TextureTag* cloudTag = (TextureTag* )(prnt->GetDown()->GetNext()->GetFirstTag());  
                                  TextureTag* atmTag = (TextureTag* )(prnt->GetDown()->GetNext()->GetNext()->GetFirstTag());  
                                    
                                  GePrint("4.1");  
                                  BaseMaterial* sMat = surfaceTag->GetMaterial();  
                                  sMat->Remove();  
                                  BaseMaterial::Free(sMat);  
                                    
                                  GePrint("4.2");  
                                  BaseMaterial* lMat = lightTag->GetMaterial();  
                                  lMat->Remove();  
                                  BaseMaterial::Free(lMat);  
                                    
                                  GePrint("4.3");  
                                  BaseMaterial* cMat = cloudTag->GetMaterial();  
                                  cMat->Remove();  
                                  BaseMaterial::Free(cMat);  
                                    
                                  GePrint("4.4");  
                                  BaseMaterial* aMat = atmTag->GetMaterial();  
                                  aMat->Remove();  
                                  BaseMaterial::Free(aMat);  
                                    
                                  GePrint("4.5");  
                          
                              }  
                        BYPASS:;  
                        GePrint("5");  
                        }  
                        
                        1 Reply Last reply Reply Quote 0
                        • H Offline
                          Helper
                          last edited by

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

                          On 29/12/2009 at 11:58, xxxxxxxx wrote:

                          Please check your TextureTag* pointers!

                          cheers,
                          Matthias

                          1 Reply Last reply Reply Quote 0
                          • H Offline
                            Helper
                            last edited by

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

                            On 30/12/2009 at 06:12, xxxxxxxx wrote:

                            Yep.  That was the problem.  I needed to check for NULL pointers for all of the pointers in this member function.   Thanks guys.

                            ~Shawn

                            1 Reply Last reply Reply Quote 0
                            • First post
                              Last post