x11drv: Fix two clipboard bugs.

Fix two clipboard problems that caused BadAtom crashes and caused some
clipboard formats to not be exported properly.
This commit is contained in:
Dan Kegel 2006-04-09 14:47:21 -07:00 committed by Alexandre Julliard
parent 12be14b6cc
commit d5292cb3f4
1 changed files with 16 additions and 8 deletions

View File

@ -1784,6 +1784,10 @@ static VOID X11DRV_CLIPBOARD_InsertSelectionProperties(Display *display, Atom* p
if (names)
{
wine_tsx11_lock();
/* FIXME: we're at the mercy of the app sending the event here.
* Currently if they send a bogus atom, we will crash.
* We should handle BadAtom errors gracefully in this call.
*/
XGetAtomNames( display, atoms, nb_atoms, names );
wine_tsx11_unlock();
for (i = 0; i < nb_atoms; i++)
@ -2790,6 +2794,13 @@ static Atom X11DRV_SelectionRequest_TARGETS( Display *display, Window requestor,
LPWINE_CLIPFORMAT lpFormats;
LPWINE_CLIPDATA lpData;
/* Create X atoms for any clipboard types which don't have atoms yet.
* This avoids sending bogus zero atoms.
* Without this, copying might not have access to all clipboard types.
* FIXME: is it safe to call this here?
*/
intern_atoms();
/*
* Count the number of items we wish to expose as selection targets.
*/
@ -2804,7 +2815,7 @@ static Atom X11DRV_SelectionRequest_TARGETS( Display *display, Window requestor,
while (lpFormats)
{
if ((lpFormats->wFormatID == lpData->wFormatID) &&
lpFormats->lpDrvExportFunc)
lpFormats->lpDrvExportFunc && lpFormats->drvData)
cTargets++;
lpFormats = lpFormats->NextFormat;
@ -2832,7 +2843,7 @@ static Atom X11DRV_SelectionRequest_TARGETS( Display *display, Window requestor,
while (lpFormats)
{
if ((lpFormats->wFormatID == lpData->wFormatID) &&
lpFormats->lpDrvExportFunc)
lpFormats->lpDrvExportFunc && lpFormats->drvData)
targets[i++] = lpFormats->drvData;
lpFormats = lpFormats->NextFormat;
@ -2848,15 +2859,12 @@ static Atom X11DRV_SelectionRequest_TARGETS( Display *display, Window requestor,
{
unsigned int i;
for ( i = 0; i < cTargets; i++)
{
if (targets[i])
{
char *itemFmtName = XGetAtomName(display, targets[i]);
TRACE("\tAtom# %d: Property %ld Type %s\n", i, targets[i], itemFmtName);
XFree(itemFmtName);
}
}
}
/* We may want to consider setting the type to xaTargets instead,
* in case some apps expect this instead of XA_ATOM */