Changeset 60772 in vbox for trunk/src/VBox/Additions/WINNT/VBoxTray
- Timestamp:
- Apr 29, 2016 9:16:24 PM (9 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/src/VBox/Additions/WINNT/VBoxTray/VBoxClipboard.cpp
r58604 r60772 95 95 } 96 96 97 98 static int vboxOpenClipboard(HWND hwnd) 99 { 100 /* "OpenClipboard fails if another window has the clipboard open." 101 * So try a few times and wait up to 1 second. 102 */ 103 int rc; 104 105 uint32_t u32SleepMS = 1; 106 int i; 107 for (i = 0; i <= 9; ++i) /* u32SleepMS = [1..512] */ 108 { 109 if (OpenClipboard(hwnd)) 110 { 111 rc = 0; 112 break; 113 } 114 rc = RTErrConvertFromWin32(GetLastError()); 115 116 RTThreadSleep(u32SleepMS); 117 u32SleepMS <<= 1; 118 } 119 #ifdef LOG_ENABLED 120 if (i > 0) 121 LogFlow(("vboxOpenClipboard: %d times tried to open clipboard. \n", ++i)); 122 #endif 123 return rc; 124 } 125 126 97 127 static int vboxClipboardChanged(PVBOXCLIPBOARDCONTEXT pCtx) 98 128 { … … 100 130 101 131 /* Query list of available formats and report to host. */ 102 int rc = VINF_SUCCESS; 103 if (FALSE == OpenClipboard(pCtx->hwnd)) 104 { 105 rc = RTErrConvertFromWin32(GetLastError()); 106 } 107 else 132 int rc = vboxOpenClipboard(pCtx->hwnd); 133 if(RT_SUCCESS(rc)) 108 134 { 109 135 uint32_t u32Formats = 0; … … 147 173 CloseClipboard(); 148 174 rc = VbglR3ClipboardReportFormats(pCtx->u32ClientID, u32Formats); 175 } 176 else 177 { 178 LogFlow(("vboxClipboardChanged: error in open clipboard. hwnd: %x. err: %Rrc\n", pCtx->hwnd, rc)); 149 179 } 150 180 return rc; … … 472 502 * windows is to be destroyed and therefore the guest side becomes inactive. 473 503 */ 474 if (OpenClipboard(hwnd)) 504 int res = vboxOpenClipboard(hwnd); 505 if (RT_SUCCESS(res)) 475 506 { 476 507 EmptyClipboard(); 477 508 CloseClipboard(); 478 509 } 510 else 511 { 512 LogFlowFunc(("WM_RENDERALLFORMATS: Failed to open clipboard! rc: %Rrc\n", res)); 513 } 479 514 } break; 480 515 … … 483 518 /* Announce available formats. Do not insert data, they will be inserted in WM_RENDER*. */ 484 519 uint32_t u32Formats = (uint32_t)lParam; 485 486 if (FALSE == OpenClipboard(hwnd)) 487 { 488 LogFlowFunc(("WM_USER: Failed to open clipboard! Last error = %ld\n", GetLastError())); 489 } 490 else 520 521 int res = vboxOpenClipboard(hwnd); 522 if(RT_SUCCESS(res)) 491 523 { 492 524 EmptyClipboard(); … … 519 551 LogFlowFunc(("WM_USER: hClip = %p, err = %ld\n", hClip, GetLastError ())); 520 552 } 553 else 554 { 555 LogFlowFunc(("WM_USER: Failed to open clipboard! error = %Rrc\n", res)); 556 } 521 557 } break; 522 558 … … 527 563 HANDLE hClip = NULL; 528 564 529 if (FALSE == OpenClipboard(hwnd)) 530 { 531 LogFlowFunc(("WM_USER: Failed to open clipboard! Last error = %ld\n", GetLastError())); 532 } 533 else 565 int res = vboxOpenClipboard(hwnd); 566 if (RT_SUCCESS(res)) 534 567 { 535 568 int vboxrc; … … 602 635 CloseClipboard(); 603 636 } 637 else 638 { 639 LogFlowFunc(("WM_USER: Failed to open clipboard! rc: %Rrc\n", res)); 640 } 604 641 605 642 if (hClip == NULL)
Note:
See TracChangeset
for help on using the changeset viewer.