Undo And Freezes?



  • 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?



  • 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



  • 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()



  • 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()



  • 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://plugincafe.maxon.net/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.



  • 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?


Log in to reply