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
    • Unread
    • Recent
    • Tags
    • Users
    • Login

    c4d crashes when plugin is open

    SDK Help
    0
    10
    797
    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
      Helper
      last edited by

      On 04/02/2014 at 11:33, xxxxxxxx wrote:

      User Information:
      Cinema 4D Version:   R15 
      Platform:   Windows  ;   
      Language(s) :     C++  ;

      ---------
      I have created a command plugin which creates a dialog and some objects.
      When I close cinema when the plugin is open, cinema crashes.
      It is ok when I close the plugin before closing cinema 4d.

      Could it be, because I allocate objects, but never "free" thems?
      If so, where and what to free?

      Or is main.cpp important? I almost commented out everything.
      Note: The plugin works fine.

      					BaseObject* sphere = BaseObject::Alloc(Osphere);
      					sphere->SetName("Alloc test");
      					doc->InsertObject(sphere, nullptr, nullptr);
      
      1 Reply Last reply Reply Quote 0
      • H
        Helper
        last edited by

        On 04/02/2014 at 15:22, xxxxxxxx wrote:

        In such a case, I comment out everything, then successively add function by function, line by line, until it chrashes again.

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

          On 05/02/2014 at 01:49, xxxxxxxx wrote:

          Wouldn't it be easier to step through with the debugger and see exactly where it crashes?

          Steve

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

            On 05/02/2014 at 03:12, xxxxxxxx wrote:

            I do not think I can step through with the debugger, because when closing down cinema 4d, I get a crash message.
            Strange enough I do not get it anymore.
            I'll try to find out, what changed and took away the crash.

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

              On 05/02/2014 at 03:22, xxxxxxxx wrote:

              Once you insert the sphere into a document, it becomes the property of the document.  You do not need to free it yourself (unless you Remove() it from the document and take ownership).

              I agree with ingvarai.  Comment all code and uncomment section by section until you hone in on the culprit.  The crash may be caused by something you never considered.

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

                On 05/02/2014 at 04:18, xxxxxxxx wrote:

                Aha.
                It only crashes when the plugin is open and the timeline is on/running (Play Forward).
                And indeed in the plugin I use frames to animated.
                Thanks for all the input.

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

                  On 05/02/2014 at 04:29, xxxxxxxx wrote:

                  Perhaps some more information.
                  I have a command plugin and in MainDialog::Message I check current frame.
                  If not equal to previous, I animate some object positions.
                  I guess this is where it goes wrong.

                  Int32 MainDialog::Message(const BaseContainer& msg, BaseContainer& result)
                  {
                  	Bool animate, addSphere;
                  	GetBool(2033,animate);
                  	
                  	if (animate)
                  	{
                  		Int32 frame, fps;
                  		BaseDocument* doc = GetActiveDocument();
                    
                  		fps = doc->GetFps();                               
                  		frame = doc->GetTime().GetFrame(fps); 
                    
                  		//GePrint ("Message frame: " + String::IntToString(curframe));
                          
                  		if (frame != currentFrame)
                  		{
                  			currentFrame = frame;
                  			....
                  
                  1 Reply Last reply Reply Quote 0
                  • H
                    Helper
                    last edited by

                    On 05/02/2014 at 04:39, xxxxxxxx wrote:

                    After GetActiveDocument(), check:

                    if (!doc) return 0;
                    

                    As C4D is closing, there may be no active document anymore.

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

                      On 05/02/2014 at 06:56, xxxxxxxx wrote:

                      Originally posted by xxxxxxxx

                      After GetActiveDocument(), check:

                      if (!doc) return 0;
                      

                      As C4D is closing, there may be no active document anymore.

                      In fact, there is no document anymore, according to my experiences.
                      In any case, it is a criminal not to check an objects existence, before making it do something. I think we have the cause nailed down!

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

                        On 06/02/2014 at 00:37, xxxxxxxx wrote:

                        Ok, clear and thanks.
                        Again a lesson learned.

                        And indeed, that was the issue!

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