浏览代码

Only return current clipboard data under X11

Fixes https://github.com/libsdl-org/SDL/issues/10192
Sam Lantinga 2 天之前
父节点
当前提交
9cf7cdf23a
共有 1 个文件被更改,包括 5 次插入0 次删除
  1. 5 0
      src/video/x11/SDL_x11clipboard.c

+ 5 - 0
src/video/x11/SDL_x11clipboard.c

@@ -273,6 +273,11 @@ bool X11_SetClipboardData(SDL_VideoDevice *_this)
 void *X11_GetClipboardData(SDL_VideoDevice *_this, const char *mime_type, size_t *length)
 void *X11_GetClipboardData(SDL_VideoDevice *_this, const char *mime_type, size_t *length)
 {
 {
     SDL_VideoData *videodata = _this->internal;
     SDL_VideoData *videodata = _this->internal;
+    if (!SDL_HasInternalClipboardData(_this, mime_type)) {
+        // This mime type wasn't advertised by the last selection owner.
+        // The atom might still have data, but it's stale, so ignore it.
+        return NULL;
+    }
     return GetSelectionData(_this, videodata->atoms.CLIPBOARD, mime_type, length);
     return GetSelectionData(_this, videodata->atoms.CLIPBOARD, mime_type, length);
 }
 }