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

    Node Crash

    Scheduled Pinned Locked Moved SDK Help
    6 Posts 0 Posters 452 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 31/10/2010 at 08:52, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   11.5 
      Platform:   Windows  ; Mac  ;  Mac OSX  ; 
      Language(s) :     C++  ;  XPRESSO  ;

      ---------
      Hi,

      I have a node with an inport that is crashing and I don´t know why.

      Here is some code:

      EditNode : public GvOperatorData  
      {  
        // Defines super  
        INSTANCEOF(EditNode, GvOperatorData)  
      public:  
        virtual Bool AddToCalculationTable(GvNode *bn, GvRun *r);  
        virtual Bool iCreateOperator(GvNode *bn);  
        Bool InitCalculation(GvNode *bn, GvCalc *c, GvRun *r)  
        {  
            return GvBuildInValuesTable(bn, ports, c, r, input_ids);     
        }  
        void FreeCalculation(GvNode *bn, GvCalc *c)  
        {  
            GvFreeValuesTable(bn, ports);  
        }  
        
        Bool Calculate(GvNode *bn, GvPort *port, GvRun *run, GvCalc *calc);  
        
        static NodeData* Alloc(void) { return gNew EditNode; }  
        
      private:  
        GvValuesInfo ports;  
      };  
        
        
      Bool EditNode::iCreateOperator(GvNode *bn)  
      {  
        BaseContainer* data = bn->GetOpContainerInstance();  
        data->SetLong(EDIT_INDEX,0);  
        if (!data) return FALSE;  
        
        return SUPER::iCreateOperator(bn);  
      }  
      Bool EditNode::AddToCalculationTable(GvNode *bn, GvRun *r)  
      {  
        return (r) && (r->AddNodeToCalculationTable(bn));  
      }  
        
      Bool EditNode::Calculate(GvNode *bn, GvPort *port, GvRun *run, GvCalc *calc)  
      {  
        BaseContainer *data = bn->GetOpContainerInstance();  
        if (!data) return FALSE;  
        
        BaseDocument* doc = bn->GetNodeMaster()->GetDocument();  
        if (!doc) return FALSE;  
        
        GvValue* vinport    = ports.in_values[EDIT_INDEX]; if (!vinport) return FALSE;  
        if (!vinport->Calculate(bn, GV_PORT_INPUT, run, calc, 0)) return FALSE; //<- HERE IT CRASHES!  
      [...]  
      }
      

      Even when it is the only node in the xpresso editor (I have not set NEEDCONNECTION in the resources) it crashes at the shown function call. Any idea why it crashes? the shown pointers are all valid, I checked in debug mode.

      This is in my resources in the ports group:

      GROUP ID_GVPORTS  
      {  
        LONG    EDIT_INDEX    {INPORT; STATICPORT; CREATEPORT;}  
      

      This happens with all my according nodes so it´s quite grave and I´d need to fix it.

      Thanks in advance!

      Thanks in advance

      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 03/11/2010 at 04:42, xxxxxxxx wrote:

        Hm, I can't find anything wrong with your code. There is one small thing (nothing to do with your problem) the check for data in EditNode::iCreateOperator should be done a line earlier.

        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 03/11/2010 at 05:25, xxxxxxxx wrote:

          Hmm, thanks first of all matthias but it anyway crashes (the data was just a mistake got in when I altered the code here for the cafe). Did you try to run that code? I have prepared a ready to compile zip project containing it which also crashes for me. I send it to you via pm.

          To make sure it´s not any mistake of other objects of mine linked to it I took everything out. So I apparently still must have something wrong in there.

          During debugging it jumps into the Calculate function and then crashes in there. 😕

          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 03/11/2010 at 06:42, xxxxxxxx wrote:

            I will look into it.

            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 03/11/2010 at 09:15, xxxxxxxx wrote:

              After looking more into your code I think the problem is this line

              GvValue* vinport = ports.in_values[FLIPEDIT_INDEX]; if (!vinport) return FALSE;
              

              It should be

              GvValue* vinport = ports.in_values[0]; if (!vinport) return FALSE;
              

              GvValuesInfo::in_values is an array to sets of input arrays. The input ports of a set of input ports can be iterated through GvValue::NrOfPorts, GvValue::GetPort.

              For instance this is the code of the Math node's Calculate method.

                
              Bool GvMathOperator::Calculate(GvNode *bn, GvPort *port, GvRun *r, GvCalc *c)  
              {  
                LONG i, j, n = 0; GvValue *v;  
                
                v = ports.in_values[GV_MATH_INPUT_INDEX]; //GV_MATH_INPUT_INDEX is 0  
                
                if (v)  
                {  
                    v->Calculate(bn,GV_PORT_INPUT,r,c,GV_MULTIPLE_PORTS);  
                
                    j = v->NrOfPorts();  
                
                    for (i = 0; i < j; ++i)  
                    {  
                        if (n == 0)  
                        {  
                            if (!v->GetPort(i)->CalculateRawData(data.data,data.data,r,GV_CALC_SET)) return FALSE;  
                        }  
                        else  
                        {  
                            if (!v->GetPort(i)->CalculateRawDataRev(data.data,data.data,r,func)) return FALSE;  
                        }  
                        ++n;  
                    }  
                }  
                if (n == 0) GvClearDynamicData(data,r);  
                
                return ports.out_ports[0]->CopyRawData(data.data,r);  
              }  
              

              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 03/11/2010 at 09:35, xxxxxxxx wrote:

                Thank you Matthias! I guess I simply haven´t thought about it, but the zero indexing makes sense now of course seeing that in_values is defined as an array. this definetly helped.

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