Access GetActiveDocument by separate threads
-
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.
-
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