mirror of
https://github.com/libsdl-org/SDL.git
synced 2026-04-21 06:45:44 +00:00
clipboard: SDL_GetClipboardText() now follows the SDL_GetStringRule.
Reference Issue #10229.
This commit is contained in:
@@ -233,7 +233,7 @@ SDL_DYNAPI_PROC(SDL_PropertiesID,SDL_GetCameraProperties,(SDL_Camera *a),(a),ret
|
||||
SDL_DYNAPI_PROC(SDL_CameraSpec*,SDL_GetCameraSupportedFormats,(SDL_CameraID a, int *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(SDL_CameraID*,SDL_GetCameras,(int *a),(a),return)
|
||||
SDL_DYNAPI_PROC(void*,SDL_GetClipboardData,(const char *a, size_t *b),(a,b),return)
|
||||
SDL_DYNAPI_PROC(char*,SDL_GetClipboardText,(void),(),return)
|
||||
SDL_DYNAPI_PROC(const char*,SDL_GetClipboardText,(void),(),return)
|
||||
SDL_DYNAPI_PROC(const SDL_DisplayMode*,SDL_GetClosestFullscreenDisplayMode,(SDL_DisplayID a, int b, int c, float d, SDL_bool e),(a,b,c,d,e),return)
|
||||
SDL_DYNAPI_PROC(const char*,SDL_GetCurrentAudioDriver,(void),(),return)
|
||||
SDL_DYNAPI_PROC(const char*,SDL_GetCurrentCameraDriver,(void),(),return)
|
||||
|
||||
@@ -2278,13 +2278,12 @@ int SDLTest_CommonEventMainCallbacks(SDLTest_CommonState *state, const SDL_Event
|
||||
SDLTest_PasteScreenShot();
|
||||
} else {
|
||||
/* Ctrl-V paste awesome text! */
|
||||
char *text = SDL_GetClipboardText();
|
||||
const char *text = SDL_GetClipboardText();
|
||||
if (*text) {
|
||||
SDL_Log("Clipboard: %s\n", text);
|
||||
} else {
|
||||
SDL_Log("Clipboard is empty\n");
|
||||
}
|
||||
SDL_free(text);
|
||||
}
|
||||
}
|
||||
break;
|
||||
|
||||
@@ -282,29 +282,31 @@ int SDL_SetClipboardText(const char *text)
|
||||
return SDL_ClearClipboardData();
|
||||
}
|
||||
|
||||
char *SDL_GetClipboardText(void)
|
||||
const char *SDL_GetClipboardText(void)
|
||||
{
|
||||
SDL_VideoDevice *_this = SDL_GetVideoDevice();
|
||||
size_t i, num_mime_types;
|
||||
const char **text_mime_types;
|
||||
size_t length;
|
||||
char *text = NULL;
|
||||
const char *text = NULL;
|
||||
|
||||
if (!_this) {
|
||||
SDL_SetError("Video subsystem must be initialized to get clipboard text");
|
||||
return SDL_strdup("");
|
||||
return "";
|
||||
}
|
||||
|
||||
text_mime_types = SDL_GetTextMimeTypes(_this, &num_mime_types);
|
||||
for (i = 0; i < num_mime_types; ++i) {
|
||||
text = (char *)SDL_GetClipboardData(text_mime_types[i], &length);
|
||||
if (text) {
|
||||
void *clipdata = SDL_GetClipboardData(text_mime_types[i], &length);
|
||||
if (clipdata) {
|
||||
text = (const char *) clipdata;
|
||||
SDL_FreeLater(clipdata); // returned string follows the SDL_GetStringRule.
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (!text) {
|
||||
text = SDL_strdup("");
|
||||
text = "";
|
||||
}
|
||||
return text;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user