From d335fc8fb04e1611352842b6f6d68f3fe43d44e9 Mon Sep 17 00:00:00 2001 From: Ulrich Sibiller Date: Sat, 30 Jan 2021 19:07:43 +0100 Subject: Clipboard.c: do not handle unknown selections in Callback handler --- nx-X11/programs/Xserver/hw/nxagent/Clipboard.c | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) (limited to 'nx-X11') diff --git a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c index b3598eef8..b77cb181a 100644 --- a/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c +++ b/nx-X11/programs/Xserver/hw/nxagent/Clipboard.c @@ -2108,11 +2108,23 @@ void nxagentSetSelectionCallback(CallbackListPtr *callbacks, void *data, } #endif + Selection * pCurSel = (Selection *)info->selection; + + int index = nxagentFindCurrentSelectionIndex(pCurSel->selection); + if (index == -1) + { + #ifdef DEBUG + fprintf(stderr, "%s: selection [%s] will not be handled by the clipboard code\n", __func__, NameForIntAtom(pCurSel->selection)); + #endif + return; + } + /* - * We do not know index here so for now let's invalidate the - * complete cache on every owner change regardless of the selection. + * always invalidate the target cache for the relevant selection, + * even if the trap is set. This ensures not having invalid data in + * the cache. */ - invalidateTargetCaches(); + invalidateTargetCache(index); if (nxagentExternalClipboardEventTrap) { @@ -2122,7 +2134,6 @@ void nxagentSetSelectionCallback(CallbackListPtr *callbacks, void *data, return; } - Selection * pCurSel = (Selection *)info->selection; #ifdef DEBUG fprintf(stderr, "%s: pCurSel->lastTimeChanged [%u]\n", __func__, pCurSel->lastTimeChanged.milliseconds); -- cgit v1.2.3