[WIN32K]
[reactos.git] / subsystems / win32 / win32k / objects / gdiobj.c
index 5af1413..70c131e 100644 (file)
@@ -8,7 +8,7 @@
 
 /** INCLUDES ******************************************************************/
 
-//#define GDI_DEBUG
+#define GDI_DEBUG
 
 #include <w32k.h>
 #define NDEBUG
@@ -819,7 +819,7 @@ GreDeleteObject(HGDIOBJ hObject)
              break;
 
           case GDI_OBJECT_TYPE_DC:
-             DC_FreeDcAttr(hObject);
+//             DC_FreeDcAttr(hObject);
              break;
        }
 
@@ -952,6 +952,8 @@ GDIOBJ_LockObj(HGDIOBJ hObj, DWORD ExpectedType)
     POBJ Object = NULL;
     ULONG HandleType, HandleUpper;
 
+    GDIDBG_INITLOOPTRACE();
+
     HandleIndex = GDI_HANDLE_GET_INDEX(hObj);
     HandleType = GDI_HANDLE_GET_TYPE(hObj);
     HandleUpper = GDI_HANDLE_GET_UPPER(hObj);
@@ -1031,6 +1033,11 @@ GDIOBJ_LockObj(HGDIOBJ hObj, DWORD ExpectedType)
                 {
                     if (Object->Tid != Thread)
                     {
+                        GDIDBG_TRACELOOP(hObj, Object->Tid, Thread);
+                        GDIDBG_TRACECALLER();
+                        GDIDBG_TRACELOCKER(GDI_HANDLE_GET_INDEX(hObj));
+                        GDIDBG_TRACEALLOCATOR(GDI_HANDLE_GET_INDEX(hObj));
+
                         /* Unlock the handle table entry. */
                         (void)InterlockedExchangePointer((PVOID*)&Entry->ProcessId, PrevProcId);
 
@@ -1059,6 +1066,7 @@ GDIOBJ_LockObj(HGDIOBJ hObj, DWORD ExpectedType)
             /*
              * The handle is currently locked, wait some time and try again.
              */
+            GDIDBG_TRACELOOP(hObj, PrevProcId, NULL);
 
             DelayExecution();
             continue;
@@ -1617,6 +1625,40 @@ GDI_MapHandleTable(PSECTION_OBJECT SectionObject, PEPROCESS Process)
     return MappedView;
 }
 
+/* Locks multiple objects at a time */
+VOID
+INTERNAL_CALL
+GDIOBJ_LockMultipleObjs(ULONG ulCount,
+                        IN HGDIOBJ* ahObj,
+                        OUT PGDIOBJ* apObj)
+{
+    UINT i;
+    HGDIOBJ hTmp ;
+    BOOL unsorted = TRUE;
+    /* We bubble-sort them */
+    while(unsorted)
+    {
+        unsorted = FALSE ;
+        for(i=0; i<ulCount - 1; i++)
+        {
+            /* The greatest the first */
+            if((ULONG_PTR)ahObj[i] < (ULONG_PTR)ahObj[i+1])
+            {
+                hTmp = ahObj[i];
+                ahObj[i]=ahObj[i+1];
+                ahObj[i+1] = hTmp;
+                unsorted = TRUE ;
+            }
+        }
+    }
+    /* Then we lock them */
+    for(i=0; i<ulCount; i++)
+    {
+        apObj[i]=GDIOBJ_LockObj(ahObj[i], GDI_OBJECT_TYPE_DONTCARE);
+    }
+}
+
+
 /** PUBLIC FUNCTIONS **********************************************************/
 
 BOOL
@@ -1709,10 +1751,9 @@ IntGdiSetDCOwnerEx( HDC hDC, DWORD OwnerMask, BOOL NoSetBrush)
   {
      pDC = DC_LockDc ( hDC );
      MmCopyFromCaller(&pDC->dcattr, pDC->pdcattr, sizeof(DC_ATTR));
+     DC_vFreeDcAttr(pDC);
      DC_UnlockDc( pDC );
 
-     DC_FreeDcAttr( hDC );         // Free the dcattr!
-
      if (!DC_SetOwnership( hDC, NULL )) // This hDC is inaccessible!
         return Ret;
   }