- Repair GDI handle debugging functionality.
- Fix locking in NtGdiGetTextFace.
Modified: trunk/reactos/subsys/win32k/objects/gdiobj.c
Modified: trunk/reactos/subsys/win32k/objects/text.c

Modified: trunk/reactos/subsys/win32k/objects/gdiobj.c
--- trunk/reactos/subsys/win32k/objects/gdiobj.c	2005-06-07 17:13:38 UTC (rev 15833)
+++ trunk/reactos/subsys/win32k/objects/gdiobj.c	2005-06-07 20:02:22 UTC (rev 15834)
@@ -559,6 +559,9 @@
          * The object is currently locked, so freeing is forbidden!
          */
         DPRINT1("GdiHdr->Locks: %d\n", GdiHdr->Locks);
+#ifdef GDI_DEBUG
+        DPRINT1("Locked from: %s:%d\n", GdiHdr->lockfile, GdiHdr->lockline);
+#endif
         ASSERT(FALSE);
       }
     }
@@ -781,6 +784,10 @@
             {
                GdiHdr->LockingThread = Thread;
                GdiHdr->Locks = 1;
+#ifdef GDI_DEBUG
+               GdiHdr->lockfile = file;
+               GdiHdr->lockline = line;
+#endif
                Object = HandleEntry->KernelData;
             }
             else
@@ -925,7 +932,15 @@
          {
             PGDIOBJHDR GdiHdr = GDIBdyToHdr(HandleEntry->KernelData);
 
+#ifdef GDI_DEBUG
+            if (InterlockedIncrement(&GdiHdr->Locks) == 1)
+            {
+               GdiHdr->lockfile = file;
+               GdiHdr->lockline = line;
+            }
+#else
             InterlockedIncrement(&GdiHdr->Locks);
+#endif
             Object = HandleEntry->KernelData;
          }
          else

Modified: trunk/reactos/subsys/win32k/objects/text.c
--- trunk/reactos/subsys/win32k/objects/text.c	2005-06-07 17:13:38 UTC (rev 15833)
+++ trunk/reactos/subsys/win32k/objects/text.c	2005-06-07 20:02:22 UTC (rev 15834)
@@ -2564,6 +2564,7 @@
 NtGdiGetTextFace(HDC hDC, INT Count, LPWSTR FaceName)
 {
    PDC Dc;
+   HFONT hFont;
    PTEXTOBJ TextObj;
    NTSTATUS Status;
 
@@ -2573,11 +2574,14 @@
       SetLastWin32Error(ERROR_INVALID_HANDLE);
       return FALSE;
    }
-   TextObj = TEXTOBJ_LockText(Dc->w.hFont);
+   hFont = Dc->w.hFont;
    DC_UnlockDc(Dc);
 
+   TextObj = TEXTOBJ_LockText(Dc->w.hFont);
+   ASSERT(TextObj != NULL);
    Count = min(Count, wcslen(TextObj->logfont.lfFaceName));
    Status = MmCopyToCaller(FaceName, TextObj->logfont.lfFaceName, Count * sizeof(WCHAR));
+   TEXTOBJ_UnlockText(TextObj);
    if (!NT_SUCCESS(Status))
    {
       SetLastNtError(Status);