mirror of
https://github.com/glfw/glfw.git
synced 2024-11-22 13:04:35 +00:00
X11: Fix returned clipboard string freed too early
The clipboard string should not be freed on SelectionClear. The user
may have received it from glfwGetClipboardString and it should remain
valid until the next call to a public clipboard string function.
(cherry picked from commit f60547ac80
)
This commit is contained in:
parent
bf5529512c
commit
946312fe93
@ -929,20 +929,6 @@ static Atom writeTargetToProperty(const XSelectionRequestEvent* request)
|
|||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
|
|
||||||
static void handleSelectionClear(XEvent* event)
|
|
||||||
{
|
|
||||||
if (event->xselectionclear.selection == _glfw.x11.PRIMARY)
|
|
||||||
{
|
|
||||||
free(_glfw.x11.primarySelectionString);
|
|
||||||
_glfw.x11.primarySelectionString = NULL;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
free(_glfw.x11.clipboardString);
|
|
||||||
_glfw.x11.clipboardString = NULL;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
static void handleSelectionRequest(XEvent* event)
|
static void handleSelectionRequest(XEvent* event)
|
||||||
{
|
{
|
||||||
const XSelectionRequestEvent* request = &event->xselectionrequest;
|
const XSelectionRequestEvent* request = &event->xselectionrequest;
|
||||||
@ -1236,12 +1222,7 @@ static void processEvent(XEvent *event)
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (event->type == SelectionClear)
|
if (event->type == SelectionRequest)
|
||||||
{
|
|
||||||
handleSelectionClear(event);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
else if (event->type == SelectionRequest)
|
|
||||||
{
|
{
|
||||||
handleSelectionRequest(event);
|
handleSelectionRequest(event);
|
||||||
return;
|
return;
|
||||||
@ -1946,10 +1927,6 @@ void _glfwPushSelectionToManagerX11(void)
|
|||||||
handleSelectionRequest(&event);
|
handleSelectionRequest(&event);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case SelectionClear:
|
|
||||||
handleSelectionClear(&event);
|
|
||||||
break;
|
|
||||||
|
|
||||||
case SelectionNotify:
|
case SelectionNotify:
|
||||||
{
|
{
|
||||||
if (event.xselection.target == _glfw.x11.SAVE_TARGETS)
|
if (event.xselection.target == _glfw.x11.SAVE_TARGETS)
|
||||||
|
Loading…
Reference in New Issue
Block a user