>  Only one branch can be expanded. (See https://www.editplus.com/
ss/editplus680x340.png)

  As a suggestion, you could simply collapse all other branches instead of
rebuilding the whole tree. This will be much faster (maybe safer?). If you
are worried about being outdated in the collapsed branches, when a branch
is opened you rebuild only that branch.

  Anyway, just committed the patch to the SVN.

Best,
Scuri


2018-02-22 23:03 GMT-03:00 云风 Cloud Wu <clou...@gmail.com>:

> Antonio Scuri <antonio.sc...@gmail.com>于2018年2月23日周五 上午12:56写道:
>
>>   Hi,
>>
>>   I run the sample here in debug, and with the release version, but the
>> problem did not appeared. I understand you are rebuilding the tree during a
>> double click. This is what you are doing in your program too or just a
>> test? I wouldn't recommend that.
>>
>
> I build iup by mingw64 (with my own makefile), but I guess it's related to
> windows version . I use windows 10 64bit (1709/16299.192)
>
> My program is complex than the test I posted. I want to map a file system
> to a tree control like editplus (https://www.editplus.com/)
>
> Only one branch can be expanded. (See https://www.editplus.com/
> ss/editplus680x340.png)
>
> For example,
>
> C:\
>   Users
>     Public
>       Documents
>           html
>
> If you double click 'Public' , 'Document' will collapsed and the branch
> removed , and `Public`  folder will be expaned like :
>
> C:\
>   Users
>     Public
>        Dir1
>        Dir2
>        Documents
>        Others
>
> So I need remove some items and add some new one here. Rebuilding may be a
> easy way to do that.
>
>
>>
>>   Anyway, I think we may test for a valid item there, but I don't think
>> that every call to GETITEM should be tested and simply return doing
>> nothing.
>>
>
> I agree, but I think we should check it here at least  .
>
> This patch can fix my problem:
>
> Index: src/win/iupwin_tree.c
> ===================================================================
> --- src/win/iupwin_tree.c       (版本 4683)
> +++ src/win/iupwin_tree.c       (工作副本)
> @@ -811,7 +811,8 @@
>    /* Get Children: branch or leaf */
>    item.mask = TVIF_HANDLE|TVIF_PARAM|TVIF_STATE;
>    item.hItem = hItem;
> -  SendMessage(ih->handle, TVM_GETITEM, 0, (LPARAM)(LPTVITEM)&item);
> +  if (!SendMessage(ih->handle, TVM_GETITEM, 0, (LPARAM)(LPTVITEM)&item))
> +         return IUP_IGNORE;
>    itemData = (winTreeItemData*)item.lParam;
>
>    if (itemData->kind == ITREE_BRANCH)
>
> If we found the Item is invalid, return  IUP_IGNORE.  It's call by
> `winTreeWmNotify`
>
>   else if(msg_info->code == TVN_ITEMEXPANDING)
>   {
>     /* mouse click by user: click on the "+" sign or double click on the
> selected node */
>     NMTREEVIEW* tree_info = (NMTREEVIEW*)msg_info;
>     HTREEITEM hItem = tree_info->itemNew.hItem;
>
>     if (winTreeCallBranchLeafCb(ih, hItem) != IUP_IGNORE)
>     {
>       TVITEM item;
>
> hItem is get from `msg_info`, it just removed from the tree when the
> problem occurs. I guess windows put the `WM_NOTIFY` message into message
> queue first, and then the items removed, but the message is still in the
> windows message queue.
>
>
>>
>>   Is there a way that I can force the sample in a situation that the
>> problem would be more likely to occur?
>>
>
> In my sample, I wrote a function do_some_systemcall() to open a file lots
> of times, and call  this function every time I add or remove tree items.
> This can trigger the bug more likely in my environment.  (without this
> function, the bug is hardly reproduced)
>
>
>>   Which IUP version are you using?
>>
>
> SVN R4683
>
>
> ------------------------------------------------------------
> ------------------
> Check out the vibrant tech community on one of the world's most
> engaging tech sites, Slashdot.org! http://sdm.link/slashdot
> _______________________________________________
> Iup-users mailing list
> Iup-users@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/iup-users
>
>
------------------------------------------------------------------------------
Check out the vibrant tech community on one of the world's most
engaging tech sites, Slashdot.org! http://sdm.link/slashdot
_______________________________________________
Iup-users mailing list
Iup-users@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/iup-users

Reply via email to