summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJon TURNEY <jon.turney@dronecode.org.uk>2009-06-19 21:14:29 +0100
committerJon TURNEY <jon.turney@dronecode.org.uk>2009-10-15 18:34:21 +0100
commitfb6d0f3c97fb24079398d1b1f1614bd1c1e1bf96 (patch)
treec4e242a775cf625e2d5ec18b07166cc230089b9c
parent1d7ba75e11563967922eab0c8a11dba7c8d480b2 (diff)
Various tidy ups in winClipboardFlushXEvents
Copyright (C) Colin Harrison 2005-2008 http://www.straightrunning.com/XmingNotes/ http://sourceforge.net/projects/xming/ Signed-off-by: Jon TURNEY <jon.turney@dronecode.org.uk>
-rw-r--r--hw/xwin/winclipboardxevents.c19
1 files changed, 18 insertions, 1 deletions
diff --git a/hw/xwin/winclipboardxevents.c b/hw/xwin/winclipboardxevents.c
index 0947d7014..fa007759e 100644
--- a/hw/xwin/winclipboardxevents.c
+++ b/hw/xwin/winclipboardxevents.c
@@ -72,7 +72,7 @@ winClipboardFlushXEvents (HWND hwnd,
/* Process all pending events */
while (XPending (pDisplay))
{
- XTextProperty xtpText = {0};
+ XTextProperty xtpText = {NULL, 0};
XEvent event;
XSelectionEvent eventSelection;
unsigned long ulReturnBytesLeft;
@@ -317,6 +317,7 @@ winClipboardFlushXEvents (HWND hwnd,
/* Initialize the text property */
xtpText.value = NULL;
+ xtpText.nitems = 0;
/* Create the text property from the text list */
if (fUseUnicode)
@@ -377,10 +378,13 @@ winClipboardFlushXEvents (HWND hwnd,
/* Release the clipboard data */
GlobalUnlock (hGlobal);
pszGlobalData = NULL;
+ fCloseClipboard = FALSE;
+ CloseClipboard ();
/* Clean up */
XFree (xtpText.value);
xtpText.value = NULL;
+ xtpText.nitems = 0;
/* Setup selection notify event */
eventSelection.type = SelectionNotify;
@@ -411,7 +415,11 @@ winClipboardFlushXEvents (HWND hwnd,
winClipboardFlushXEvents_SelectionRequest_Done:
/* Free allocated resources */
if (xtpText.value)
+ {
XFree (xtpText.value);
+ xtpText.value = NULL;
+ xtpText.nitems = 0;
+ }
if (pszConvertData)
free (pszConvertData);
if (hGlobal && pszGlobalData)
@@ -452,7 +460,10 @@ winClipboardFlushXEvents (HWND hwnd,
/* Close clipboard if it was opened */
if (fCloseClipboard)
+ {
+ fCloseClipboard = FALSE;
CloseClipboard ();
+ }
break;
@@ -634,6 +645,7 @@ winClipboardFlushXEvents (HWND hwnd,
/* Conversion succeeded or some unconvertible characters */
if (ppszTextList != NULL)
{
+ iReturnDataLen = 0;
for (i = 0; i < iCount; i++)
{
iReturnDataLen += strlen(ppszTextList[i]);
@@ -679,6 +691,7 @@ winClipboardFlushXEvents (HWND hwnd,
ppszTextList = NULL;
XFree (xtpText.value);
xtpText.value = NULL;
+ xtpText.nitems = 0;
/* Convert the X clipboard string to DOS format */
XLockDisplay (pDisplay);
@@ -794,7 +807,11 @@ winClipboardFlushXEvents (HWND hwnd,
if (ppszTextList)
XFreeStringList (ppszTextList);
if (xtpText.value)
+ {
XFree (xtpText.value);
+ xtpText.value = NULL;
+ xtpText.nitems = 0;
+ }
if (pszConvertData)
free (pszConvertData);
if (pwszUnicodeStr)