C4D freezes when updating Active Tool tab



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 16/06/2006 at 06:41, xxxxxxxx wrote:

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

    ---------
    I have written a tool plugin. When updating the Active Tool tab, C4D sometimes freezes. To isolate the problem, I used the following code:

      
    LONG Tool::Draw(BaseDocument* doc, BaseContainer& data, BaseDraw* bd, BaseDrawHelp* bh, BaseThread* bt, LONG flags)  
    {  
        BaseObject *o = doc->GetActiveObject();  
        if (o == obj) return 0;  
        obj = o;  
        if (!dialog) return 0;  
        Real r;  
        dialog->GetReal(10001, r);  
        dialog->SetReal(10001, r+1);  
        return 0;  
    }  
    

    - dialog is the dialog created and returned in AllocSubDialog
    - obj is used to store the active object

    This code updates the tool dialog when a different object is selected, but it seems to cause a deadlock. C4D R8 freezes only sometimes, C4D R9 always when dialog->SetReal is executed (but only, if a different value is set). My idea was to reset the tool parameters when a different object is selected, but I skipped this feature due to the deadlock.

    Now, someone using my plugin reports a similar problem when updating the tool dialog while interacting with the tool using the mouse. I can't reproduce the problem in C4D R9, but R9.5 seems to freeze sometimes when the dialog id updated from Tool::MouseInput. My tool has handles for some parameters, so it is important that I can update the parameters in the dialog when they are modified using the handles.

    Is this kind of problem with updating the Active Tool tab known to anyone, and does someone know a way around it?



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 27/06/2006 at 03:44, xxxxxxxx wrote:

    I believe it's not safe to do this in ::Draw(), since it can be called from a thread other than the GUI thread. The safe way is to use a message plugin, so that you can defer the updating of the dialog to the GUI thread. An example of this method is found in the thread http://www.plugincafe.com/forum/display_topic_threads.asp?ForumID=4&TopicID=1852



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 28/06/2006 at 06:48, xxxxxxxx wrote:

    Thanks for the info about how to do thread-safe, asynchronous updates with a MessagePlugin in C4D.

    However, while I understand that doing the update in Draw might by critical regarding threads, I wonder a bit that it is also for MouseInput in C4D 9.6.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 03/07/2006 at 11:00, xxxxxxxx wrote:

    I do not know if MouseInput() is thread safe or not, but I have asked the developers to clarify this and will get back to you when I know more.



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 08/07/2006 at 04:25, xxxxxxxx wrote:

    I just got a reply from the developers that ToolData::MouseInput() happens in the main thread, and so GUI functions should be allowed there. (While ToolData::Draw() is not, thus GUI functions are disallowed.)



  • THE POST BELOW IS MORE THAN 5 YEARS OLD. RELATED SUPPORT INFORMATION MIGHT BE OUTDATED OR DEPRECATED

    On 09/07/2006 at 10:51, xxxxxxxx wrote:

    Thanks again for the info.

    I can't reproduce the problem with MouseInput myself. I added an option in my plugin to turn off the Active Tool update from MouseInput. Since this solved the problem for those who reported the problem to me, I think there's nothing more I can do about this.


Log in to reply