Nikolay Sivov : oleview: Use Treeview notifications to release created instances.

Alexandre Julliard julliard at winehq.org
Mon Feb 6 16:31:18 CST 2017


Module: wine
Branch: master
Commit: 4c55ea3e1c52410ceeb2093a25f2a67088669757
URL:    http://source.winehq.org/git/wine.git/?a=commit;h=4c55ea3e1c52410ceeb2093a25f2a67088669757

Author: Nikolay Sivov <nsivov at codeweavers.com>
Date:   Mon Feb  6 01:28:01 2017 +0300

oleview: Use Treeview notifications to release created instances.

Signed-off-by: Nikolay Sivov <nsivov at codeweavers.com>
Signed-off-by: Alexandre Julliard <julliard at winehq.org>

---

 programs/oleview/oleview.c |  2 +-
 programs/oleview/tree.c    | 48 ++++++++++++++--------------------------------
 2 files changed, 15 insertions(+), 35 deletions(-)

diff --git a/programs/oleview/oleview.c b/programs/oleview/oleview.c
index f1713b8..d1877b0 100644
--- a/programs/oleview/oleview.c
+++ b/programs/oleview/oleview.c
@@ -469,8 +469,8 @@ static LRESULT CALLBACK WndProc(HWND hWnd, UINT uMsg,
             MenuCommand(LOWORD(wParam), hWnd);
             break;
         case WM_DESTROY:
-            OleUninitialize();
             EmptyTree();
+            OleUninitialize();
             PostQuitMessage(0);
             break;
         case WM_MENUSELECT:
diff --git a/programs/oleview/tree.c b/programs/oleview/tree.c
index decedc4..2a4ca65 100644
--- a/programs/oleview/tree.c
+++ b/programs/oleview/tree.c
@@ -604,40 +604,7 @@ static void AddBaseEntries(void)
 
 void EmptyTree(void)
 {
-    HTREEITEM cur, del;
-    TVITEMW tvi;
-
-    tvi.mask = TVIF_PARAM;
-    cur = (HTREEITEM)SendMessageW(globals.hTree, TVM_GETNEXTITEM,
-            TVGN_CHILD, (LPARAM)TVI_ROOT);
-
-    while(TRUE)
-    {
-        del = cur;
-        cur = (HTREEITEM)SendMessageW(globals.hTree, TVM_GETNEXTITEM,
-                TVGN_CHILD, (LPARAM)del);
-
-        if(!cur) cur = (HTREEITEM)SendMessageW(globals.hTree,
-                TVM_GETNEXTITEM, TVGN_NEXT, (LPARAM)del);
-        if(!cur)
-        {
-            cur = (HTREEITEM)SendMessageW(globals.hTree, TVM_GETNEXTITEM,
-                    TVGN_PREVIOUS, (LPARAM)del);
-            if(!cur) cur = (HTREEITEM)SendMessageW(globals.hTree,
-                    TVM_GETNEXTITEM, TVGN_PARENT, (LPARAM)del);
-
-            tvi.hItem = del;
-            if(SendMessageW(globals.hTree, TVM_GETITEMW, 0, (LPARAM)&tvi) && tvi.lParam)
-            {
-                if(((ITEM_INFO *)tvi.lParam)->loaded) ReleaseInst(del);
-                HeapFree(GetProcessHeap(), 0, (ITEM_INFO *)tvi.lParam);
-
-                SendMessageW(globals.hTree, TVM_DELETEITEM, 0, (LPARAM)del);
-            }
-
-            if(!cur) break;
-        }
-    }
+    SendMessageW(globals.hTree, TVM_DELETEITEM, 0, (LPARAM)TVI_ROOT);
 }
 
 void AddTreeEx(void)
@@ -678,6 +645,19 @@ static LRESULT CALLBACK TreeProc(HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lPa
                     RefreshMenu(((NMTREEVIEWW *)lParam)->itemNew.hItem);
                     RefreshDetails(((NMTREEVIEWW *)lParam)->itemNew.hItem);
                     break;
+                case TVN_DELETEITEMW:
+                {
+                    NMTREEVIEWW *nm = (NMTREEVIEWW*)lParam;
+                    ITEM_INFO *info = (ITEM_INFO*)nm->itemOld.lParam;
+
+                    if (info)
+                    {
+                        if (info->loaded)
+                            ReleaseInst(nm->itemOld.hItem);
+                        HeapFree(GetProcessHeap(), 0, info);
+                    }
+                    break;
+                }
             }
             break;
         case WM_SIZE:




More information about the wine-cvs mailing list