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

    Access GetActiveDocument by separate threads

    SDK Help
    0
    2
    198
    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 28/11/2016 at 10:58, xxxxxxxx wrote:

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

      ---------
      Hello.

      I have a non-main thread, which needs to read the Hierarchy Objects from GetActiveDocument().
      I'm not sure if this is safe, because at the same time, the user might modify these objects. 
      I assume that if the second thread simply reads the objects there will be no issue right ?

      Thank you for your time.

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

        On 29/11/2016 at 01:36, xxxxxxxx wrote:

        Hello,

        as you already said, a user might modify the scene while your custom thread is reading the scene. So when the user deletes an object you are accessing the result is an unavoidable crash.

        So it is not save to do anything with the active document from another thread than the main thread. Either parse the active document from the main thread or parse a copy of the document in your custom thread.

        See also the BaseDocument Manual and the "What exactly does StopAllThreads do" discussion.

        best wishes,
        Sebastian

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