[WIN32K]
authorTimo Kreuzer <timo.kreuzer@reactos.org>
Sun, 13 May 2012 18:29:31 +0000 (18:29 +0000)
committerTimo Kreuzer <timo.kreuzer@reactos.org>
Sun, 13 May 2012 18:29:31 +0000 (18:29 +0000)
- In DC_vSetOwner, do not take ownership of the current dc brush and pen, instead dereference them and select default brush and pen. Fixes bug #7070
- Fix debug logging in GDIOBJ_vDereferenceObject
- create debug log event in GDIOBJ_vSetObjectOwner

svn path=/trunk/; revision=56579

reactos/win32ss/gdi/ntgdi/dclife.c
reactos/win32ss/gdi/ntgdi/gdiobj.c

index 03efa6f..3d6c3e8 100644 (file)
@@ -414,8 +414,19 @@ DC_vSetOwner(PDC pdc, ULONG ulOwner)
         GreSetObjectOwner(pdc->dclevel.hPath, ulOwner);
     }
 
-    IntGdiSetBrushOwner(pdc->dclevel.pbrFill, ulOwner);
-    IntGdiSetBrushOwner(pdc->dclevel.pbrLine, ulOwner);
+    /* Dereference current brush and pen */
+    BRUSH_ShareUnlockBrush(pdc->dclevel.pbrFill);
+    BRUSH_ShareUnlockBrush(pdc->dclevel.pbrLine);
+
+    /* Select the default fill and line brush */
+    pdc->dcattr.hbrush = StockObjects[WHITE_BRUSH];
+    pdc->dcattr.hpen = StockObjects[BLACK_PEN];
+    pdc->dclevel.pbrFill = BRUSH_ShareLockBrush(pdc->pdcattr->hbrush);
+    pdc->dclevel.pbrLine = PEN_ShareLockPen(pdc->pdcattr->hpen);
+
+    /* Update the EBRUSHOBJs */
+    EBRUSHOBJ_vUpdate(&pdc->eboFill, pdc->dclevel.pbrFill, pdc);
+    EBRUSHOBJ_vUpdate(&pdc->eboLine, pdc->dclevel.pbrLine, pdc);
 
     /* Allocate or free DC attribute */
     if (ulOwner == GDI_OBJ_HMGR_PUBLIC || ulOwner == GDI_OBJ_HMGR_NONE)
index e0234a1..6b82c34 100644 (file)
@@ -476,18 +476,16 @@ GDIOBJ_vDereferenceObject(POBJ pobj)
 {
     ULONG cRefs, ulIndex;
 
-    /* Log the event */
-    DBG_LOGEVENT(&pobj->slhLog, EVENT_DEREFERENCE, cRefs);
+    /* Calculate the index */
+    ulIndex = GDI_HANDLE_GET_INDEX(pobj->hHmgr);
 
     /* Check if the object has a handle */
-    if (GDI_HANDLE_GET_INDEX(pobj->hHmgr))
+    if (ulIndex)
     {
-        /* Calculate the index */
-        ulIndex = GDI_HANDLE_GET_INDEX(pobj->hHmgr);
-
         /* Decrement reference count */
         ASSERT((gpaulRefCount[ulIndex] & REF_MASK_COUNT) > 0);
         cRefs = InterlockedDecrement((LONG*)&gpaulRefCount[ulIndex]);
+        DBG_LOGEVENT(&pobj->slhLog, EVENT_DEREFERENCE, cRefs);
 
         /* Check if we reached 0 and handle bit is not set */
         if ((cRefs & REF_MASK_INUSE) == 0)
@@ -517,6 +515,7 @@ GDIOBJ_vDereferenceObject(POBJ pobj)
         /* Decrement the objects reference count */
         ASSERT(pobj->ulShareCount > 0);
         cRefs = InterlockedDecrement((LONG*)&pobj->ulShareCount);
+        DBG_LOGEVENT(&pobj->slhLog, EVENT_DEREFERENCE, cRefs);
 
         /* Check if we reached 0 */
         if (cRefs == 0)
@@ -777,6 +776,7 @@ GDIOBJ_vSetObjectOwner(
 
     /* Set new owner */
     pentry->ObjectOwner.ulObj = ulOwner;
+    DBG_LOGEVENT(&pobj->slhLog, EVENT_SET_OWNER, 0);
 }
 
 /* Locks 2 or 3 objects at a time */