Skip to content

Add note about checking SDL_CLIPBOARDUPDATE in Wiki CategoryClipboard before calling SDL_GetClipboardText() #12063

Open
@inflex

Description

@inflex

Happy to do this myself if possible but thought I'd bring this issue up, if nothing else for anyone else who gets a head-scratching "bug" here (manifests as stalling/stuttering/loss-of-fps due to time consumption);

At the time of writing, SDL_GetClipboardText() is a time-expensive call under linux and it's poor usage by oneself would have potentially been avoided if it was noted in the Wiki CategoryClipboard that it may be worth checking for SDL_CLIPBOARDUPDATE in the event structure before needlessly calling SDL_GetClipboardText().

I was running around lookin for a SDL_IsClipboardChanged() or similar function, so that was my bad assumption there.

			if (event.type == SDL_CLIPBOARDUPDATE) {
				if (SDL_HasClipboardText()) {
					char *cbt = SDL_GetClipboardText();
					if (cbt) {
                                                // Do something with the text
					}
					SDL_free(cbt);
				}
			}

Very likely the use of SDL_HasClipboardText() may be redundant here for my use case but I added it for thoroughness.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions