Use a linked list instead of a DPA to manage pixmaps.
This commit is contained in:
parent
617f6908de
commit
96ebf15edd
@ -64,7 +64,6 @@
|
|||||||
#include "windef.h"
|
#include "windef.h"
|
||||||
#include "x11drv.h"
|
#include "x11drv.h"
|
||||||
#include "bitmap.h"
|
#include "bitmap.h"
|
||||||
#include "commctrl.h"
|
|
||||||
#include "heap.h"
|
#include "heap.h"
|
||||||
#include "options.h"
|
#include "options.h"
|
||||||
#include "debugtools.h"
|
#include "debugtools.h"
|
||||||
@ -90,12 +89,14 @@ static unsigned long cSelectionTargets = 0; /* Number of target formats repor
|
|||||||
static Atom selectionCacheSrc = XA_PRIMARY; /* The selection source from which the clipboard cache was filled */
|
static Atom selectionCacheSrc = XA_PRIMARY; /* The selection source from which the clipboard cache was filled */
|
||||||
static HANDLE selectionClearEvent = 0;/* Synchronization object used to block until server is started */
|
static HANDLE selectionClearEvent = 0;/* Synchronization object used to block until server is started */
|
||||||
|
|
||||||
/*
|
typedef struct tagPROPERTY
|
||||||
* Dynamic pointer arrays to manage destruction of Pixmap resources
|
{
|
||||||
*/
|
struct tagPROPERTY *next;
|
||||||
static HDPA PropDPA = NULL;
|
Atom atom;
|
||||||
static HDPA PixmapDPA = NULL;
|
Pixmap pixmap;
|
||||||
|
} PROPERTY;
|
||||||
|
|
||||||
|
static PROPERTY *prop_head;
|
||||||
|
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
@ -833,22 +834,13 @@ void X11DRV_CLIPBOARD_Release()
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* Get rid of any Pixmap resources we may still have */
|
/* Get rid of any Pixmap resources we may still have */
|
||||||
if (PropDPA)
|
while (prop_head)
|
||||||
DPA_Destroy( PropDPA );
|
|
||||||
if (PixmapDPA)
|
|
||||||
{
|
{
|
||||||
int i;
|
PROPERTY *prop = prop_head;
|
||||||
Pixmap pixmap;
|
prop_head = prop->next;
|
||||||
for( i = 0; ; i++ )
|
XFreePixmap( display, prop->pixmap );
|
||||||
{
|
HeapFree( GetProcessHeap(), 0, prop );
|
||||||
if ( (pixmap = ((Pixmap)DPA_GetPtr(PixmapDPA, i))) )
|
|
||||||
XFreePixmap(display, pixmap);
|
|
||||||
else
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
DPA_Destroy( PixmapDPA );
|
|
||||||
}
|
}
|
||||||
PixmapDPA = PropDPA = NULL;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
@ -895,12 +887,6 @@ void X11DRV_CLIPBOARD_Acquire()
|
|||||||
|
|
||||||
if (selectionAcquired)
|
if (selectionAcquired)
|
||||||
{
|
{
|
||||||
/* Create dynamic pointer arrays to manage Pixmap resources we may expose */
|
|
||||||
if (!PropDPA)
|
|
||||||
PropDPA = DPA_CreateEx( 2, SystemHeap );
|
|
||||||
if (!PixmapDPA)
|
|
||||||
PixmapDPA = DPA_CreateEx( 2, SystemHeap );
|
|
||||||
|
|
||||||
selectionWindow = owner;
|
selectionWindow = owner;
|
||||||
TRACE("Grabbed X selection, owner=(%08x)\n", (unsigned) owner);
|
TRACE("Grabbed X selection, owner=(%08x)\n", (unsigned) owner);
|
||||||
}
|
}
|
||||||
@ -1217,13 +1203,13 @@ END:
|
|||||||
*/
|
*/
|
||||||
BOOL X11DRV_CLIPBOARD_RegisterPixmapResource( Atom property, Pixmap pixmap )
|
BOOL X11DRV_CLIPBOARD_RegisterPixmapResource( Atom property, Pixmap pixmap )
|
||||||
{
|
{
|
||||||
if ( -1 == DPA_InsertPtr( PropDPA, 0, (void*)property ) )
|
PROPERTY *prop = HeapAlloc( GetProcessHeap(), 0, sizeof(*prop) );
|
||||||
return FALSE;
|
if (!prop) return FALSE;
|
||||||
|
prop->atom = property;
|
||||||
if ( -1 == DPA_InsertPtr( PixmapDPA, 0, (void*)pixmap ) )
|
prop->pixmap = pixmap;
|
||||||
return FALSE;
|
prop->next = prop_head;
|
||||||
|
prop_head = prop;
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**************************************************************************
|
/**************************************************************************
|
||||||
@ -1237,28 +1223,18 @@ void X11DRV_CLIPBOARD_FreeResources( Atom property )
|
|||||||
/* Do a simple linear search to see if we have a Pixmap resource
|
/* Do a simple linear search to see if we have a Pixmap resource
|
||||||
* associated with this property and release it.
|
* associated with this property and release it.
|
||||||
*/
|
*/
|
||||||
int i;
|
PROPERTY **prop = &prop_head;
|
||||||
Pixmap pixmap;
|
|
||||||
Atom cacheProp = 0;
|
while (*prop)
|
||||||
for( i = 0; ; i++ )
|
|
||||||
{
|
{
|
||||||
if ( !(cacheProp = ((Atom)DPA_GetPtr(PropDPA, i))) )
|
if ((*prop)->atom == property)
|
||||||
break;
|
|
||||||
|
|
||||||
if ( cacheProp == property )
|
|
||||||
{
|
{
|
||||||
/* Lookup the associated Pixmap and free it */
|
PROPERTY *next = (*prop)->next;
|
||||||
pixmap = (Pixmap)DPA_GetPtr(PixmapDPA, i);
|
XFreePixmap( display, (*prop)->pixmap );
|
||||||
|
HeapFree( GetProcessHeap(), 0, *prop );
|
||||||
TRACE("Releasing pixmap %ld for Property %s\n",
|
*prop = next;
|
||||||
(long)pixmap, TSXGetAtomName(display, cacheProp));
|
|
||||||
|
|
||||||
XFreePixmap(display, pixmap);
|
|
||||||
|
|
||||||
/* Free the entries from the table */
|
|
||||||
DPA_DeletePtr(PropDPA, i);
|
|
||||||
DPA_DeletePtr(PixmapDPA, i);
|
|
||||||
}
|
}
|
||||||
|
else prop = &(*prop)->next;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user