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

    Undo And Freezes?

    Scheduled Pinned Locked Moved PYTHON Development
    6 Posts 0 Posters 593 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

      On 16/03/2017 at 14:28, xxxxxxxx wrote:

      I'm currently developing a plugin that uses a TreeView to add/modify selection tags on the active object. It's doing basically everything I want, but I'm getting a reproducible freeze when I hit Undo multiple times in quick succession.

      I've stripped out all of the CallCommand()s from my code so I'm creating all of the undo steps myself.

      1. Are there any common culprits for freezes (not crashes)?

      2. Is there a negative consequence for using StartUndo() but failing to properly close it with EndUndo()

      3. Could this be a threading issue? If so, how often do I need to call c4d.StopAllThreads()? At the start of a method, or before every API call that modifies the scene?

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

        On 16/03/2017 at 15:50, xxxxxxxx wrote:

        This sounds a lot like the TreeGui quirk I've seen using it in R13.
        In R13 the treeGUI is very slow. And I noticed that it can crash C4D when using it to add, or delete things in the document too quickly.
        It works fine if you don't click too fast. But it's definitely a bit risky to use it this way.
        Hence the giant "Not Supported" warnings I posted on my TreeGui example.

        If you wait a couple of seconds between executing each undo. Does it still crash?

        -ScottA

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

          On 17/03/2017 at 10:02, xxxxxxxx wrote:

          Hi,

          We are aware there's a reproducible freeze with the TreeViewCustomGui while doing several undo operations in a short time.

          Originally posted by xxxxxxxx

          1. Are there any common culprits for freezes (not crashes)?

          Freezes can occur because of infinite loops or processing, dead locks etc.

          Originally posted by xxxxxxxx

          2. Is there a negative consequence for using StartUndo() but failing to properly close it with EndUndo()

          It's highly recommended to call StartUndo()/EndUndo() in pair. If EndUndo() does not get called, the undo stack will be corrupt.

          Originally posted by xxxxxxxx

          3. Could this be a threading issue? If so, how often do I need to call c4d.StopAllThreads()? At the start of a method, or before every API call that modifies the scene?

          It is enough to call StopAllThreads() once before changing the active document.
          The sequence of calls should be:
          - StopAllThreads()
          - StartUndo() to start an undo action
          - Modify document with optional AddUndo() calls
          - EndUndo() to finish the undo action
          - EventAdd()

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

            On 17/03/2017 at 10:22, xxxxxxxx wrote:

            Hi Yannick & ScottA,

            It does seem at least partly related to the quick undo issue. When a user selects or creates a new selection tag via the TreeView, an Undo step is added. It feels like a quick Undo might somehow be triggering an endless loop - perhaps related to the auto-generation of undo steps based on selection changes.

            I'll go back through my code and ensure that all AddUndo/EndUndos get closed.

            Thanks for the information on how best to handle c4d.StopAllThreads()

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

              On 17/03/2017 at 15:30, xxxxxxxx wrote:

              I had a sus**cion the issue was caused by wrapping my BaseList2D objects in a custom Python class - I was right! Directly using BaseList2D that exist in the document solved my freezes caused by quick Undo statements. Unfortunately, I'm back to my old problem of no longer having support for Arrow Keys or Shift-Clicking of elements:

              https://developers.maxon.net/forum/topic/9546/12810_treeview-shift-click--keyboard-arrows-input

              It seems that the TreeView's Select() method doesn't get called on native BaseList2D elements, which apparently leads to some issues with supporting up/down arrows.

              I'll keep at it, and let you know if I find a workaround.

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

                On 29/03/2017 at 11:00, xxxxxxxx wrote:

                Originally posted by xxxxxxxx

                We are aware there's a reproducible freeze with the TreeViewCustomGui while doing several undo operations in a short time.

                My attempts to circumvent this have been fruitless, which kills my plugin. 😕 Is this a Python-specific issue or is it a problem with the C++ SDK as well? Any recommendations on what to avoid or how to code around it?

                Do you have code which you can use to trigger this issue, or would it be helpful for me to send you source?

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