TreeViewF and C4D crash



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

    On 31/12/2004 at 21:21, xxxxxxxx wrote:

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

    ---------
    I realize that the TreeViewCustomGUI isn't *really* supported in 8.012, but it is available and does work - well, mostly.

    When a tree is unfolded and a mouse button is depressed while the mouse is in an open area (not over an item), all of the hierarchy is processed with the inevitable crash of Cinema 4D (unless you wait for the entire hierarchy to process - which is several thousand items).

    This does not occur in later versions of Cinema 4D, only 8.012.

    Here is my TreeViewFunctions code:

      
    class TVFunctions : public TreeViewFunctions  
    {  
         public:  
              virtual void* GetFirst(void *root, void *userdata)  
              {  
                   return ((TreeRoot* )root)->GetFirst();  
              }  
              virtual void* GetNext(void *root, void *userdata, void *obj)  
              {  
                   return ((RuntimeItem* )obj)->GetNext();  
              }  
              virtual void* GetPred(void *root, void *userdata, void *obj)  
              {  
                   return ((RuntimeItem* )obj)->GetPrev();  
              }  
              virtual void* GetDown(void *root, void *userdata, void *obj)  
              {  
                   return ((RuntimeItem* )obj)->GetChild();  
              }  
              virtual Bool IsSelected(void *root, void *userdata, void *obj)  
              {  
                   return (RuntimeItem* )obj == ((TreeRoot* )root)->GetSelected();  
              }  
              virtual String GetName(void *root, void *userdata, void *obj)  
              {  
                   return ((RuntimeItem* )obj)->GetSimpleName();  
              }  
              virtual void SetName(void *root, void* userdata, void* obj, const String& str)  
              {  
              }  
              virtual LONG GetId(void *root, void *userdata, void *obj)  
              {  
                   return ((RuntimeItem* )obj)->GetID();  
              }  
              virtual void GetColors(void *root, void *userdata, void *obj, GeData* pNormal, GeData* pSelected)  
              {  
                   *pNormal = ((TreeRoot* )root)->GetColorNormal(((RuntimeItem* )obj)->GetType());  
                   *pSelected = ((TreeRoot* )root)->GetColorSelected(((RuntimeItem* )obj)->GetType());  
              }  
              virtual Bool IsOpened(void *root, void *userdata, void *obj)  
              {  
                   return ((RuntimeItem* )obj)->GetBit(RTFLAGS_EXPANDED);  
              }  
              virtual void Open(void *root, void *userdata, void *obj, Bool onoff)  
              {  
                   if (onoff)     ((RuntimeItem* )obj)->SetBit(RTFLAGS_EXPANDED);  
                   else          ((RuntimeItem* )obj)->DelBit(RTFLAGS_EXPANDED);  
              }  
              virtual void Select(void *root, void *userdata, void *obj, LONG mode)  
              {  
                   ((TreeRoot* )root)->SetSelected((RuntimeItem* )obj);  
              }  
              virtual LONG AcceptDragObject(void *root, void *userdata, void *obj, LONG dragtype, void *dragobject, Bool &bAllowCopy;)  
              {  
                   return 0;  
              }  
              virtual void InsertObject(void *root, void *userdata, void *obj, LONG dragtype, void *dragobject, LONG insertmode, Bool bCopy)  
              {  
              }  
              virtual LONG GetDragType(void *root, void *userdata, void *obj)  
              {  
                   return NOTOK;  
              }  
              virtual Bool DoubleClick(void *root, void *userdata, void *obj, LONG col, MouseInfo *mouseinfo)  
              {  
                   return ((TreeRoot* )root)->ProcessRuntimeItem((RuntimeItem* )obj);  
              }  
              virtual Bool MouseDown(void *root, void *userdata, void *obj, LONG col, MouseInfo *mouseinfo, Bool rightButton)  
              {  
                   return FALSE;  
              }  
              virtual LONG GetColumnWidth(void *root, void *userdata, void *obj, LONG col)   
              {  
                   return 0;  
              }  
              virtual LONG GetLineHeight(void *root, void *userdata, void *obj, LONG col)  
              {  
                   return 0;  
              }  
              virtual void DrawCell(void *root, void *userdata, void *obj, LONG col, DrawInfo *drawinfo, LONG bgColor)  
              {  
              }  
    } functable;  
    

    Have no clue what is happening or how to prevent it.

    Thanks,
    Robert



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

    On 01/01/2005 at 01:00, xxxxxxxx wrote:

    Quote: Originally posted by kuroyume0161 on 31 December 2004
    >
    > * * *
    >
    > User Information:
    >
    > Cinema 4D Version:   8.012 </br>Platform:   Windows ;   </br>Language(s) :    C++ ; </br>
    >
    > ---------
    >
    > I realize that the TreeViewCustomGUI isn't *really* supported in 8.012, but it is available and does work - well, mostly.
    >
    > <CODE>
    > class TVFunctions : public TreeViewFunctions
    > {
    >      public:
    > [...]
    >           virtual LONG GetColumnWidth(void *root, void *userdata, void *obj, LONG col)
    >           {
    >                return 0;
    >           }
    >           virtual LONG GetLineHeight(void *root, void *userdata, void *obj, LONG col)
    >           {
    >                return 0;
    >           }
    > [...]
    > } functable;
    > </CODE>
    >
    >
    > * * *

    GetLineHeight should never return 0 since this will lead to an integer division by zero. You must return a positive number > 0 here. The column width should be > 0, too.



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

    On 01/01/2005 at 06:46, xxxxxxxx wrote:

    This is from MAXON's ActiveObject.cpp SDK example:

      
              virtual LONG GetColumnWidth(void *root,void *userdata,void *obj,LONG col)   
              {   
                   if (col=='icon')  
                   {  
                        if (((BaseList2D* )obj)->IsInstanceOf(Obase))  
                        {  
                             return 24;  
                        }  
                        else if (((BaseList2D* )obj)->IsInstanceOf(Mbase))  
                        {  
                             return 24;  
                        }  
                   }  
                   return 0;  
              }  
      
              virtual LONG GetLineHeight(void *root,void *userdata,void *obj,LONG col)  
              {  
                   if (col=='icon')  
                   {  
                        if (((BaseList2D* )obj)->IsInstanceOf(Obase))  
                        {  
                             return 24;  
                        }  
                        else if (((BaseList2D* )obj)->IsInstanceOf(Mbase))  
                        {  
                             return 24;  
                        }  
                   }  
                   return 0;  
              }  
    

    What were you saying?

    Robert



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

    On 01/01/2005 at 08:04, xxxxxxxx wrote:

    Quote: Originally posted by kuroyume0161 on 01 January 2005
    >
    > * * *
    >
    > This is from MAXON's ActiveObject.cpp SDK example:
    >
    > What were you saying?
    >
    > Robert
    >
    >
    > * * *

    I said that you should not return 0 (since I have crashed one of my tree views with this, too). That's why I have added this comment in the R9 API ;-)

      
    virtual LONG           GetLineHeight(void *root,void *userdata,void *obj,LONG col, GeUserArea* area); // always return a value > 0 !  
    

    GetLineHeight is called for each column and the biggest of these values is taken. But since you have a LV_TREE column, the line height will always be > 0.

    Does "(unless you wait for the entire hierarchy to process - which is several thousand items)" mean that you can still work with Cinema after a some time or does it really crash (with an error message)?



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

    On 01/01/2005 at 08:56, xxxxxxxx wrote:

    I'm not using the R9 API. ;0)

    What should I return then? These are not fixed in height or width, but are set by the GUI depending upon the dialogs dimensions (etc.).

    If I attempt to do anything in C4D while it's processing, it will immediately go to "not responding" and need to be killed. If I wait until it's finished fifteen or twenty minutes later, it continues to work.

    This does not happen under 8.503 or 9.012 (C4D version) - same plugin compiled using R8.012 SDK.

    Thanks,
    Robert



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

    On 01/01/2005 at 09:41, xxxxxxxx wrote:

    I should also mention that the only column in my Tree is the text hierarchy - 'tree' LV_TREE - there are no icons. Can I just not implement these methods (I think that I tried this previously and received compiler errors - not certain)?

    Robert



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

    On 01/01/2005 at 10:30, xxxxxxxx wrote:

    If you only have a LV_TREE column you can leave this part of your code as it is.
    Could you please comment out the line
    ((TreeRoot* )root)->SetSelected((RuntimeItem* )obj);
    and test the speed? If this doesn't speed it up much I don't have more ideas...



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

    On 01/01/2005 at 11:11, xxxxxxxx wrote:

    'Kay. That solves the problem, but it renders my tree useless. I need to know which folder is selected in order to do that 'processing' that I don't want happening across all of the tree items when the mouse button is clicked beyond the right of the list. It is almost as if there is a 'ghost' column to the right of the tree hierarchy - again, only in 8.012.

    When a folder is selected and it contains files, file icons are displayed in another ListView (and the selected RuntimeItem pointer is stored in TreeRoot). Without Select(), I cannot do this.

    But, I don't want every folder Visited (hint) when a mouse button is clicked to the right & outside of the tree list text (column).

    See, this is what you get for only making one example of TreeViewCustomGui using all internal C4D features and not much else to go by. I used the ActiveObject.cpp example because that is IT.

    If I knew how to restrict the column width in a manner like Object Manager, that might avoid this without crippling the functionality of my plugin. ;/

    Robert



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

    On 01/01/2005 at 11:24, xxxxxxxx wrote:

    This means that you have to optimize your SetSelected function ;-)
    First, you should check the value of mode. It may be SELECTION_NEW (obj will be the only selected element in the tree), SELECTION_ADD (add obj to the current selection) and SELECTION_SUB (remove obj from the selection). Currently you call SetSelected even if the item is deselected. It could happen that Select(..., SELECTION_SUB) is called for each item to deselect it if the user clicks outside the tree column.



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

    On 01/01/2005 at 11:31, xxxxxxxx wrote:

    Yes, the mode. That's what made the difference.

      
              virtual void Select(void *root, void *userdata, void *obj, LONG mode)  
              {  
                   if (mode) return;  
                   ((TreeRoot* )root)->SetSelected((RuntimeItem* )obj);  
              }  
    

    When clicking to the right & outside, mode is set to 2 while it is set to 0 when clicking on an item. Problem solved!

    Thanks,
    Robert



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

    On 01/01/2005 at 11:58, xxxxxxxx wrote:

    You should check if mode != SELECTION_SUB instead of != 0. SELECTION_NEW is used when the user clicks on the element with the right mosue button. You will lose this event if you only check for != 0.



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

    On 01/01/2005 at 12:43, xxxxxxxx wrote:

    Actually, SELECTION_NEW is exactly what I want and it works in all versions (8.0, 8.2, 8.5, and 9.0). :) There is no multi-select, so the selection is always new, not add (?).



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

    On 01/01/2005 at 12:57, xxxxxxxx wrote:

    Quote: Originally posted by kuroyume0161 on 01 January 2005
    >
    > * * *
    >
    > There is no multi-select, so the selection is always new, not add (?).
    >
    >
    > * * *

    It may be add if the user holds down the shift key and sub if ctrl is pressed. You could treat add as new and ignore sub.


Log in to reply