VirtualBox

Changeset 61908 in vbox


Ignore:
Timestamp:
Jun 28, 2016 1:24:52 AM (8 years ago)
Author:
vboxsync
Message:

fix for ​​​​bugref:8441: improved windows procedures in Clipboard, DND and HostPowerWin.

Location:
trunk/src/VBox
Files:
4 edited

Legend:

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

    r60784 r61908  
    659659        } break;
    660660
     661        case WM_DESTROY:
     662        {
     663            vboxClipboardRemoveFromCBChain(pCtx);
     664            if (pCtx->timerRefresh)
     665                KillTimer(pCtx->hwnd, 0);
     666            /*
     667             * don't need to call PostQuitMessage cause
     668             * the VBoxTray already finished a message loop
     669             */
     670        } break;
     671
    661672        default:
    662673        {
     
    732743    if (pCtx->hwnd)
    733744    {
    734         vboxClipboardRemoveFromCBChain(pCtx);
    735         if (pCtx->timerRefresh)
    736             KillTimer(pCtx->hwnd, 0);
    737 
    738745        DestroyWindow(pCtx->hwnd);
    739746        pCtx->hwnd = NULL;
  • trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxDnD.cpp

    r59844 r61908  
    289289        {
    290290            MSG uMsg;
    291             while (GetMessage(&uMsg, 0, 0, 0))
     291            BOOL fRet;
     292            while ((fRet = GetMessage(&uMsg, 0, 0, 0)) > 0)
    292293            {
    293294                TranslateMessage(&uMsg);
    294295                DispatchMessage(&uMsg);
    295296            }
     297            Assert(fRet >= 0);
    296298
    297299            if (ASMAtomicReadBool(&pCtx->fShutdown))
  • trunk/src/VBox/HostServices/SharedClipboard/VBoxClipboard-win.cpp

    r61724 r61908  
    6262
    6363    RTTHREAD thread;
    64     bool volatile fTerminate;
    6564
    6665    HANDLE hRenderEvent;
     
    649648        } break;
    650649
    651         case WM_CLOSE:
    652         {
    653             /* Do nothing. Ignore the message. */
     650        case WM_DESTROY:
     651        {
     652            /* MS recommends to remove from Clipboard chain in this callback */
     653            Assert(pCtx->hwnd);
     654            removeFromCBChain(pCtx);
     655            if (pCtx->timerRefresh)
     656                KillTimer(pCtx->hwnd, 0);
     657            PostQuitMessage(0);
    654658        } break;
    655659
     
    716720
    717721            MSG msg;
    718             while (GetMessage(&msg, NULL, 0, 0) && !pCtx->fTerminate)
     722            BOOL msgret = 0;
     723            while ((msgret = GetMessage(&msg, NULL, 0, 0)) > 0)
    719724            {
    720725                TranslateMessage(&msg);
    721726                DispatchMessage(&msg);
    722727            }
    723         }
    724     }
    725 
    726     if (pCtx->hwnd)
    727     {
    728         removeFromCBChain(pCtx);
    729         if (pCtx->timerRefresh)
    730             KillTimer(pCtx->hwnd, 0);
    731 
    732         DestroyWindow (pCtx->hwnd);
    733         pCtx->hwnd = NULL;
    734     }
     728            /*
     729            * Window procedure can return error,
     730            * but this is exceptional situation
     731            * that should be identified in testing
     732            */
     733            Assert(msgret >= 0);
     734            Log(("VBoxClipboardThread Message loop finished. GetMessage returned %d, message id: %d \n", msgret, msg.message));
     735        }
     736    }
     737
     738    pCtx->hwnd = NULL;
    735739
    736740    if (atomWindowClass != 0)
     
    772776    Log(("vboxClipboardDestroy\n"));
    773777
    774     /* Set the termination flag and ping the window thread. */
    775     ASMAtomicWriteBool (&g_ctx.fTerminate, true);
    776 
    777778    if (g_ctx.hwnd)
    778779    {
    779         PostMessage (g_ctx.hwnd, WM_CLOSE, 0, 0);
     780        int rc = PostMessage (g_ctx.hwnd, WM_CLOSE, 0, 0);
    780781    }
    781782
  • trunk/src/VBox/Main/src-server/win/HostPowerWin.cpp

    r60052 r61908  
    5454        Log(("HostPowerServiceWin::!HostPowerServiceWin: destroy window %x\n", mHwnd));
    5555
    56         /* Is this allowed from another thread? */
    57         SetWindowLongPtr(mHwnd, 0, 0);
    5856        /* Poke the thread out of the event loop and wait for it to clean up. */
    59         PostMessage(mHwnd, WM_QUIT, 0, 0);
     57        PostMessage(mHwnd, WM_CLOSE, 0, 0);
    6058        RTThreadWait(mThread, 5000, NULL);
    6159        mThread = NIL_RTTHREAD;
     
    117115            MSG msg;
    118116            BOOL fRet;
    119             while ((fRet = GetMessage(&msg, NULL, 0, 0)) != 0)
     117            while ((fRet = GetMessage(&msg, NULL, 0, 0)) > 0)
    120118            {
    121                 if (fRet != -1)
    122                 {
    123                     TranslateMessage(&msg);
    124                     DispatchMessage(&msg);
    125                 }
    126                 else
    127                 {
    128                     // handle the error and possibly exit
    129                     break;
    130                 }
     119                TranslateMessage(&msg);
     120                DispatchMessage(&msg);
    131121            }
     122            /*
     123            * Window procedure can return error,
     124            * but this is exceptional situation
     125            * that should be identified in testing
     126            */
     127            Assert(fRet >= 0);
    132128        }
    133129    }
    134130
    135131    Log(("HostPowerServiceWin::NotificationThread: exit thread\n"));
    136     if (hwnd)
    137         DestroyWindow(hwnd);
    138132
    139133    if (atomWindowClass != 0)
     
    214208        }
    215209
     210        case WM_DESTROY:
     211        {
     212            /* moved here. it can't work across theads */
     213            SetWindowLongPtr(hwnd, 0, 0);
     214            PostQuitMessage(0);
     215            return 0;
     216        }
     217
    216218        default:
    217219            return DefWindowProc(hwnd, msg, wParam, lParam);
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