VirtualBox

Changeset 80965 in vbox for trunk/src


Ignore:
Timestamp:
Sep 24, 2019 9:49:34 AM (5 years ago)
Author:
vboxsync
Message:

Shared Clipboard/Transfers: Use take critical section in WM_CLIPBOARDUPDATE in VBoxTray.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp

    r80918 r80965  
    433433    switch (msg)
    434434    {
    435        case WM_CLIPBOARDUPDATE:
    436        {
    437            const HWND hWndClipboardOwner = GetClipboardOwner();
    438 
    439            LogFunc(("WM_CLIPBOARDUPDATE: hWndOldClipboardOwner=%p, hWndNewClipboardOwner=%p\n",
    440                     pWinCtx->hWndClipboardOwnerUs, hWndClipboardOwner));
    441 
    442            if (pWinCtx->hWndClipboardOwnerUs != hWndClipboardOwner)
    443            {
    444                /* Clipboard was updated by another application.
    445                 * Report available formats to the host. */
    446                SHCLFORMATDATA Formats;
    447                int rc = SharedClipboardWinGetFormats(&pCtx->Win, &Formats);
    448                if (RT_SUCCESS(rc))
    449                {
    450                    LogFunc(("WM_CLIPBOARDUPDATE: Reporting formats 0x%x\n", Formats.uFormats));
    451                    rc = VbglR3ClipboardFormatsSend(&pCtx->CmdCtx, &Formats);
    452                }
    453            }
    454 
    455            break;
    456        }
     435        case WM_CLIPBOARDUPDATE:
     436        {
     437            LogFunc(("WM_CLIPBOARDUPDATE: Waiting ...\n"));
     438
     439            int rc = RTCritSectEnter(&pWinCtx->CritSect);
     440            if (RT_SUCCESS(rc))
     441            {
     442                const HWND hWndClipboardOwner = GetClipboardOwner();
     443
     444                LogFunc(("WM_CLIPBOARDUPDATE: hWndOldClipboardOwner=%p, hWndNewClipboardOwner=%p\n",
     445                         pWinCtx->hWndClipboardOwnerUs, hWndClipboardOwner));
     446
     447                if (pWinCtx->hWndClipboardOwnerUs != hWndClipboardOwner)
     448                {
     449                    int rc2 = RTCritSectLeave(&pWinCtx->CritSect);
     450                    AssertRC(rc2);
     451
     452                    /* Clipboard was updated by another application.
     453                     * Report available formats to the host. */
     454                    SHCLFORMATDATA Formats;
     455                    int rc = SharedClipboardWinGetFormats(&pCtx->Win, &Formats);
     456                    if (RT_SUCCESS(rc))
     457                    {
     458                        LogFunc(("WM_CLIPBOARDUPDATE: Reporting formats 0x%x\n", Formats.uFormats));
     459                        rc = VbglR3ClipboardFormatsSend(&pCtx->CmdCtx, &Formats);
     460                    }
     461                }
     462                else
     463                {
     464                    int rc2 = RTCritSectLeave(&pWinCtx->CritSect);
     465                    AssertRC(rc2);
     466                }
     467            }
     468
     469            if (RT_FAILURE(rc))
     470                LogRel(("Shared Clipboard: WM_CLIPBOARDUPDATE failed with %Rrc\n", rc));
     471
     472            break;
     473        }
    457474
    458475       case WM_CHANGECBCHAIN:
Note: See TracChangeset for help on using the changeset viewer.

© 2024 Oracle Support Privacy / Do Not Sell My Info Terms of Use Trademark Policy Automated Access Etiquette