summaryrefslogtreecommitdiff
path: root/hw/xwin/winclipboardxevents.c
diff options
context:
space:
mode:
authorHarold L Hunt II <huntharo@msu.edu>2004-01-15 06:06:44 +0000
committerHarold L Hunt II <huntharo@msu.edu>2004-01-15 06:06:44 +0000
commitd0f8eb52b3caf81d180c6dc92318278344fc46f3 (patch)
treec3daaccd4a6403e73ad97c9edd6e38b782a4f55c /hw/xwin/winclipboardxevents.c
parentd1b62d8fe9babcd40c84c0a75d1786c4ff01a20f (diff)
Sync with XWin Server 4.3.0-41 release. Lots of minor cleanups to enable
the code to build in the xserver tree (almost).
Diffstat (limited to 'hw/xwin/winclipboardxevents.c')
-rw-r--r--hw/xwin/winclipboardxevents.c56
1 files changed, 41 insertions, 15 deletions
diff --git a/hw/xwin/winclipboardxevents.c b/hw/xwin/winclipboardxevents.c
index 708621bb9..eb495cb41 100644
--- a/hw/xwin/winclipboardxevents.c
+++ b/hw/xwin/winclipboardxevents.c
@@ -465,10 +465,11 @@ winClipboardFlushXEvents (HWND hwnd,
atomLocalProperty,
iWindow,
CurrentTime);
- if (iReturn == BadAtom || iReturn == BadWindow)
+ if (iReturn != Success)
{
ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
- "XConvertSelection () failed\n");
+ "XConvertSelection () failed, aborting: %d\n",
+ iReturn);
break;
}
@@ -488,10 +489,11 @@ winClipboardFlushXEvents (HWND hwnd,
atomLocalProperty,
iWindow,
CurrentTime);
- if (iReturn == BadAtom || iReturn == BadWindow)
+ if (iReturn != Success)
{
ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
- "XConvertSelection () failed\n");
+ "XConvertSelection () failed, aborting: %d\n",
+ iReturn);
break;
}
@@ -502,7 +504,8 @@ winClipboardFlushXEvents (HWND hwnd,
else
{
ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
- "Unknown format. Cannot request conversion.\n");
+ "Unknown format. Cannot request conversion, "
+ "aborting.\n");
break;
}
}
@@ -523,7 +526,8 @@ winClipboardFlushXEvents (HWND hwnd,
if (iReturn != Success)
{
ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
- "XGetWindowProperty () failed, aborting.\n");
+ "XGetWindowProperty () failed, aborting: %d\n",
+ iReturn);
break;
}
@@ -548,7 +552,8 @@ winClipboardFlushXEvents (HWND hwnd,
if (iReturn != Success)
{
ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
- "XGetWindowProperty () failed, aborting.\n");
+ "XGetWindowProperty () failed, aborting: %d\n",
+ iReturn);
break;
}
@@ -600,26 +605,25 @@ winClipboardFlushXEvents (HWND hwnd,
else
{
ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
- "X*TextPropertyToTextList list_return is NULL\n");
+ "X*TextPropertyToTextList list_return is NULL.\n");
pszReturnData = malloc (1);
pszReturnData[0] = '\0';
}
}
else
{
+ ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
+ "X*TextPropertyToTextList returned: ");
switch (iReturn)
{
case XNoMemory:
- ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
- "XNoMemory\n");
+ ErrorF ("XNoMemory\n");
break;
case XConverterNotFound:
- ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
- "XConverterNotFound\n");
+ ErrorF ("XConverterNotFound\n");
break;
default:
- ErrorF ("winClipboardFlushXEvents - SelectionNotify - "
- "Unknown Error\n");
+ ErrorF ("%d", iReturn);
break;
}
pszReturnData = malloc (1);
@@ -627,7 +631,8 @@ winClipboardFlushXEvents (HWND hwnd,
}
/* Free the data returned from XGetWindowProperty */
- XFreeStringList (ppszTextList);
+ if (ppszTextList)
+ XFreeStringList (ppszTextList);
ppszTextList = NULL;
XFree (xtpText.value);
xtpText.value = NULL;
@@ -648,6 +653,15 @@ winClipboardFlushXEvents (HWND hwnd,
/* Allocate memory for the Unicode string */
pwszUnicodeStr
= (wchar_t*) malloc (sizeof (wchar_t) * (iUnicodeLen + 1));
+ if (!pwszUnicodeStr)
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionNotify "
+ "malloc failed for pwszUnicodeStr, aborting.\n");
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionNotify_Done;
+ }
/* Do the actual conversion */
MultiByteToWideChar (CP_UTF8,
@@ -670,6 +684,18 @@ winClipboardFlushXEvents (HWND hwnd,
hGlobal = GlobalAlloc (GMEM_MOVEABLE, iConvertDataLen);
}
+ /* Check that global memory was allocated */
+ if (!hGlobal)
+ {
+ ErrorF ("winClipboardFlushXEvents - SelectionNotify "
+ "GlobalAlloc failed, aborting: %ld\n",
+ GetLastError ());
+
+ /* Abort */
+ fAbort = TRUE;
+ goto winClipboardFlushXEvents_SelectionNotify_Done;
+ }
+
/* Obtain a pointer to the global memory */
pszGlobalData = GlobalLock (hGlobal);
if (pszGlobalData == NULL)