| Summary: | X11: Clipboard API needs a window | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Imants <capsexe> |
| Component: | video | Assignee: | Ryan C. Gordon <icculus> |
| Status: | RESOLVED FIXED | QA Contact: | Sam Lantinga <slouken> |
| Severity: | normal | ||
| Priority: | P2 | CC: | flibitijibibo, philipp.wiesemann |
| Version: | 2.0.4 | ||
| Hardware: | x86_64 | ||
| OS: | Linux | ||
| Attachments: | Test program | ||
I tried same in CodeBlocks result was little different but failure still
SDL_SetClipboardText("SDL Tutorial");
int rez = SDL_HasClipboardText(); //rez was 0
if (rez)
{
title = SDL_GetClipboardText();
}
else
{
title = "fail"; //got this value
}
I was idiot and forgot to call SDL_Init(SDL_INIT_EVERYTHING) in code blocks. After that application crashed as in my pascal code. Created attachment 2355 [details]
Test program
Can you try this test program and see if it still has problems? It'll create a window, print what's currently on the clipboard to stdout, and then put whatever you had on the command line on the clipboard (which you can see by pasting it somewhere). The otherwise-useless SDL window will hang around until you close it to end the program.
Just trying to narrow down the problem here.
--ryan.
Ok now I understand. On Linux SDL_HasClipboardText and SDL_GetClipboardText crashes if I call them before I create SDL_window or do not create it at all. On Windows it works properly in bought cases. I do not see why should I create SDL_Window to use clipboard functionality but I do know that It should not crash system :). And there is no documentation that this should work together with SDL_Window :\ (In reply to Imants from comment #4) > Ok now I understand. On Linux SDL_HasClipboardText and SDL_GetClipboardText > crashes if I call them before I create SDL_window or do not create it at > all. On Windows it works properly in bought cases. I do not see why should I > create SDL_Window to use clipboard functionality but I do know that It > should not crash system :). And there is no documentation that this should > work together with SDL_Window :\ Yeah, X11 requires a window for this. But we could handle this better (maybe making a temporary window, or at least not crashing). I'll leave this open for now while we figure out what to do. --ryan. I would be contented if it would be mentioned in documentation, it would not crash and SDL_GetError() would return error message why it is not working. *** Bug 3718 has been marked as a duplicate of this bug. *** This bug is now fixed in https://hg.libsdl.org/SDL/rev/3767cdd2d64b ...we had already fixed the crashing if SDL_Init(SDL_INIT_VIDEO) wasn't called, but now you don't need to have created an SDL_Window to interact with the X11 clipboard. --ryan. |
I am using libSDL2-2.0.so.0.4.0 witch I have compiled myself. When I try to get clipboard text or try to check if there is clipboard text my application gangs and stop responding indefinitely. code example: SDL_SetClipboardText('Test'); AssertTrue('SDL_HasClipboardText', SDL_HasClipboardText() = SDL_TRUE); AssertEquals('Test', SDL_GetClipboardText());