Author: hbelusca
Date: Sun Feb 14 01:52:58 2016
New Revision: 70738
URL:
http://svn.reactos.org/svn/reactos?rev=70738&view=rev
Log:
[CLIPBRD]
- Avoid calling OpenClipboard with a NULL window handle.
- Display the clipboard erasing confirmation message before actually opening and resetting
its contents.
[WIN32K]
- Improve few comments.
- In UserOpenClipboard, return success early in case the clipboard was already opened by
the clipboard owner.
Modified:
trunk/reactos/base/applications/clipbrd/clipbrd.c
trunk/reactos/base/applications/clipbrd/winutils.c
trunk/reactos/win32ss/user/ntuser/clipboard.c
Modified: trunk/reactos/base/applications/clipbrd/clipbrd.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/clipbrd/…
==============================================================================
--- trunk/reactos/base/applications/clipbrd/clipbrd.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/clipbrd/clipbrd.c [iso-8859-1] Sun Feb 14 01:52:58
2016
@@ -65,17 +65,21 @@
static void LoadClipboardDataFromFile(LPWSTR lpszFileName)
{
+ if (MessageBoxRes(Globals.hMainWnd, Globals.hInstance,
+ STRING_DELETE_MSG, STRING_DELETE_TITLE,
+ MB_ICONWARNING | MB_YESNO) != IDYES)
+ {
+ return;
+ }
+
if (!OpenClipboard(Globals.hMainWnd))
{
ShowLastWin32Error(Globals.hMainWnd);
return;
}
- if (MessageBoxRes(Globals.hMainWnd, Globals.hInstance, STRING_DELETE_MSG,
STRING_DELETE_TITLE, MB_ICONWARNING | MB_YESNO) == IDYES)
- {
- EmptyClipboard();
- ReadClipboardFile(lpszFileName);
- }
+ EmptyClipboard();
+ ReadClipboardFile(lpszFileName);
CloseClipboard();
}
@@ -227,10 +231,14 @@
case CMD_DELETE:
{
- if (MessageBoxRes(Globals.hMainWnd, Globals.hInstance, STRING_DELETE_MSG,
STRING_DELETE_TITLE, MB_ICONWARNING | MB_YESNO) == IDYES)
- {
- DeleteClipboardContent();
- }
+ if (MessageBoxRes(Globals.hMainWnd, Globals.hInstance,
+ STRING_DELETE_MSG, STRING_DELETE_TITLE,
+ MB_ICONWARNING | MB_YESNO) != IDYES)
+ {
+ break;
+ }
+
+ DeleteClipboardContent();
break;
}
@@ -272,10 +280,8 @@
PAINTSTRUCT ps;
RECT rc;
- if (!OpenClipboard(NULL))
- {
- return;
- }
+ if (!OpenClipboard(Globals.hMainWnd))
+ return;
hdc = BeginPaint(hWnd, &ps);
GetClientRect(hWnd, &rc);
Modified: trunk/reactos/base/applications/clipbrd/winutils.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/base/applications/clipbrd/…
==============================================================================
--- trunk/reactos/base/applications/clipbrd/winutils.c [iso-8859-1] (original)
+++ trunk/reactos/base/applications/clipbrd/winutils.c [iso-8859-1] Sun Feb 14 01:52:58
2016
@@ -243,7 +243,7 @@
UINT uResult;
HDC hDevContext;
- if (!OpenClipboard(NULL))
+ if (!OpenClipboard(Globals.hMainWnd))
{
return GDI_ERROR;
}
Modified: trunk/reactos/win32ss/user/ntuser/clipboard.c
URL:
http://svn.reactos.org/svn/reactos/trunk/reactos/win32ss/user/ntuser/clipbo…
==============================================================================
--- trunk/reactos/win32ss/user/ntuser/clipboard.c [iso-8859-1] (original)
+++ trunk/reactos/win32ss/user/ntuser/clipboard.c [iso-8859-1] Sun Feb 14 01:52:58 2016
@@ -124,7 +124,7 @@
static BOOL FASTCALL
IntIsClipboardOpenByMe(PWINSTATION_OBJECT pWinSta)
{
- /* Check if current thread has opened the clipboard */
+ /* Check if the current thread has opened the clipboard */
return (pWinSta->ptiClipLock &&
pWinSta->ptiClipLock == PsGetCurrentThreadWin32Thread());
}
@@ -386,7 +386,7 @@
if (!pWinStaObj)
goto cleanup;
- /* Check if clipboard has been opened */
+ /* Check if the clipboard has been opened */
if (!IntIsClipboardOpenByMe(pWinStaObj))
{
EngSetLastError(ERROR_CLIPBOARD_NOT_OPEN);
@@ -433,18 +433,22 @@
if (!pWinStaObj)
goto cleanup;
- if (pWinStaObj->ptiClipLock)
- {
- /* Clipboard is already opened */
- if (pWinStaObj->spwndClipOpen != pWindow)
- {
- ERR("Access denied!\n");
- EngSetLastError(ERROR_ACCESS_DENIED);
- goto cleanup;
- }
- }
-
- /* Open clipboard */
+ /* Check if we already opened the clipboard */
+ if ((pWindow == pWinStaObj->spwndClipOpen) &&
IntIsClipboardOpenByMe(pWinStaObj))
+ {
+ bRet = TRUE;
+ goto cleanup;
+ }
+
+ /* If the clipboard was already opened by somebody else, bail out */
+ if ((pWindow != pWinStaObj->spwndClipOpen) && pWinStaObj->ptiClipLock)
+ {
+ ERR("Access denied!\n");
+ EngSetLastError(ERROR_ACCESS_DENIED);
+ goto cleanup;
+ }
+
+ /* Open the clipboard */
pWinStaObj->spwndClipOpen = pWindow;
pWinStaObj->ptiClipLock = PsGetCurrentThreadWin32Thread();
bRet = TRUE;
@@ -478,7 +482,7 @@
if (!pWinStaObj)
goto cleanup;
- /* Check if clipboard has been opened */
+ /* Check if the clipboard has been opened */
if (!IntIsClipboardOpenByMe(pWinStaObj))
{
EngSetLastError(ERROR_CLIPBOARD_NOT_OPEN);
@@ -613,7 +617,7 @@
if (!pWinStaObj)
return FALSE;
- /* Check if clipboard has been opened */
+ /* Check if the clipboard has been opened */
if (!IntIsClipboardOpenByMe(pWinStaObj))
{
EngSetLastError(ERROR_CLIPBOARD_NOT_OPEN);
@@ -834,7 +838,7 @@
if (!pWinStaObj)
goto cleanup;
- /* Check if clipboard has been opened */
+ /* Check if the clipboard has been opened */
if (!IntIsClipboardOpenByMe(pWinStaObj))
{
EngSetLastError(ERROR_CLIPBOARD_NOT_OPEN);