- Properly remove window properties when destroying the window.
authorJames Tabor <james.tabor@reactos.org>
Wed, 16 Oct 2013 00:11:23 +0000 (00:11 +0000)
committerJames Tabor <james.tabor@reactos.org>
Wed, 16 Oct 2013 00:11:23 +0000 (00:11 +0000)
svn path=/trunk/; revision=60684

reactos/win32ss/user/ntuser/prop.c
reactos/win32ss/user/ntuser/prop.h
reactos/win32ss/user/ntuser/window.c

index 9b03ba4..105aa89 100644 (file)
@@ -16,12 +16,12 @@ IntGetProp(PWND Window, ATOM Atom)
 {
    PLIST_ENTRY ListEntry;
    PPROPERTY Property;
+   int i;
 
    ListEntry = Window->PropListHead.Flink;
-   while (ListEntry != &Window->PropListHead)
+   for (i = 0; i < Window->PropListItems; i++ )
    {
       Property = CONTAINING_RECORD(ListEntry, PROPERTY, PropListEntry);
-      if (!Property) break;
       if (Property->Atom == Atom)
       {
          return(Property);
@@ -79,6 +79,25 @@ IntSetProp(PWND pWnd, ATOM Atom, HANDLE Data)
    return TRUE;
 }
 
+VOID FASTCALL
+IntRemoveWindowProp(PWND Window)
+{
+   PLIST_ENTRY ListEntry;
+   PPROPERTY Property;
+   int i, Count = Window->PropListItems;
+
+   ListEntry = Window->PropListHead.Flink;
+   for (i = 0; i < Count; i++ )
+   {
+      Property = CONTAINING_RECORD(ListEntry, PROPERTY, PropListEntry);
+      ListEntry = ListEntry->Flink;
+      RemoveEntryList(&Property->PropListEntry);
+      UserHeapFree(Property);
+      Window->PropListItems--;
+   }
+   return;
+}
+
 /* FUNCTIONS *****************************************************************/
 
 NTSTATUS APIENTRY
index 9ba3eaf..fdde50a 100644 (file)
@@ -4,3 +4,4 @@ PPROPERTY FASTCALL IntGetProp(PWND,ATOM);
 BOOL FASTCALL IntRemoveProp(PWND,ATOM);
 BOOL FASTCALL IntSetProp(PWND, ATOM, HANDLE);
 HANDLE FASTCALL UserGetProp(PWND, ATOM);
+VOID FASTCALL IntRemoveWindowProp(PWND Window);
index 5aa8ee9..52255f3 100644 (file)
@@ -426,8 +426,6 @@ static LRESULT co_UserFreeWindow(PWND Window,
    PWND Child;
    PMENU_OBJECT Menu;
    BOOLEAN BelongsToThreadData;
-   PLIST_ENTRY ListEntry;
-   PPROPERTY Property;
 
    ASSERT(Window);
 
@@ -556,12 +554,11 @@ static LRESULT co_UserFreeWindow(PWND Window,
 
    IntUnlinkWindow(Window);
 
-   ListEntry = Window->PropListHead.Flink;
-   while (ListEntry != &Window->PropListHead)
+   if (Window->PropListItems)
    {
-       Property = CONTAINING_RECORD(ListEntry, PROPERTY, PropListEntry);
-       ListEntry = ListEntry->Flink;
-       IntRemoveProp(Window, Property->Atom);
+      IntRemoveWindowProp(Window);
+      TRACE("Window->PropListItems %d\n",Window->PropListItems);
+      ASSERT(Window->PropListItems==0);
    }
 
    UserReferenceObject(Window);