[WIN32K] -NtUserEmptyClipboard: Change its behaviour to wait for WM_DESTROYCLIPBOARD...
[reactos.git] / reactos / win32ss / user / ntuser / clipboard.c
index e2a93e1..9790b86 100644 (file)
@@ -448,9 +448,14 @@ UserEnumClipboardFormats(UINT fmt)
     {
         /* Return next format */
         pElement = IntGetFormatElement(pWinStaObj, fmt);
-        ++pElement;
-        if (pElement < &pWinStaObj->pClipBase[pWinStaObj->cNumClipFormats])
-            Ret = pElement->fmt;
+        if (pElement != NULL)
+        {
+            ++pElement;
+            if (pElement < &pWinStaObj->pClipBase[pWinStaObj->cNumClipFormats])
+            {
+                Ret = pElement->fmt;
+            }
+        }
     }
 
 cleanup:
@@ -675,7 +680,7 @@ UserEmptyClipboard(VOID)
     {
         TRACE("Clipboard: WM_DESTROYCLIPBOARD to %p\n", pWinStaObj->spwndClipOwner->head.h);
         // For 32-bit applications this message is sent as a notification
-        co_IntSendMessageNoWait(pWinStaObj->spwndClipOwner->head.h, WM_DESTROYCLIPBOARD, 0, 0);
+        co_IntSendMessage(pWinStaObj->spwndClipOwner->head.h, WM_DESTROYCLIPBOARD, 0, 0);
     }
 
     pWinStaObj->spwndClipOwner = pWinStaObj->spwndClipOpen;
@@ -982,15 +987,7 @@ UserSetClipboardData(UINT fmt, HANDLE hData, PSETCLIPBDATA scd)
     if (!pWinStaObj)
         goto cleanup;
 
-    /*
-     * Check if the clipboard is correctly opened:
-     * - in case of normal rendering, we must have opened the clipboard;
-     * - in case of delayed rendering, the clipboard must be already opened
-     *   by another application, but we need to be the clipboard owner.
-     */
-    if ((!pWinStaObj->fInDelayedRendering && !IntIsClipboardOpenByMe(pWinStaObj)) ||
-        (pWinStaObj->fInDelayedRendering && !(pWinStaObj->ptiClipLock &&
-         pWinStaObj->spwndClipOwner->head.pti == PsGetCurrentThreadWin32Thread())))
+    if (!fmt || !pWinStaObj->ptiClipLock)
     {
         ERR("Access denied!\n");
         EngSetLastError(ERROR_CLIPBOARD_NOT_OPEN);