Opened 9 years ago

Closed 4 years ago

#3145 closed defect (fixed)

Copy & Paste need to paste two times to get correct contents

Reported by: elexis Owned by:
Priority: Should Have Milestone: Alpha 24
Component: Core engine Keywords:
Cc: Patch: Phab:D2476

Description (last modified by temple)

Most of the time I need to press ctrl+v two times to get the correct clipboard contents.

I open 0ad, get into the game lobby, enter some text, copy or cut it (ctrl+c or ctrl+x) and paste it (ctrl+v).

Result: It pasted no text. If I press ctrl+v again it pastes the correct text.

If I copy from another application, the pasted string is sometimes correct when pasting the first time.

Change History (13)

comment:1 by historic_bruno, 9 years ago

Milestone: Alpha 19Backlog

Which OS is this and which version of the game?

comment:2 by elexis, 9 years ago

Im using ubuntu 14.10 with i3 window manager. I had this bug both on a17 and a18.

It were good if someone else could check if he/she has this problem too....

comment:3 by elexis, 9 years ago

Also im using SDL 2.

comment:4 by trompetin17, 9 years ago

I tested in osx yosemite and it worked ok

comment:5 by elexis, 9 years ago

I compiled the current a19 / svn version with SDL1 and the bug occurs too.

comment:6 by elexis, 9 years ago

Crashes appear now too the more I play with ctrl+c and ctrl+v. Happened in the setup of a hosted game too.

comment:7 by elexis, 9 years ago

Fortunately the application prints debug messges!

For each ctrl+c:

sys_clipboard_set: <clipboard contents>

and for each ctrl+v:

clipboard_get: XGetWindowProperty succeeded, returning data
clipboard_get: data was: "<clipboard content>", type was 31, XA_STRING atom is 31

And the bug appears in the log as follows:

sys_clipboard_set: test2
clipboard_get: XGetWindowProperty succeeded, returning data
clipboard_get: data was: "test1", type was 31, XA_STRING atom is 31
clipboard_get: XGetWindowProperty succeeded, returning data
clipboard_get: data was: "test2", type was 31, XA_STRING atom is 31

So although the sys_clipboard_set function was called, the result of clipboard_get is not test2 but test1 in this case.


In fact I can copy text as often as I want - the first pasted string after copying text will always be the last pasted string [or empty string].


Last but not least my poor 0ad crashes frequently when copy/pasting with the following error:

X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  18 (X_ChangeProperty)
  Resource id in failed request:  0x1804c8e
  Serial number of failed request:  7494
  Current serial number in output stream:  7496
X Error of failed request:  BadWindow (invalid Window parameter)
  Major opcode of failed request:  25 (X_SendEvent)
  Resource id in failed request:  0x1804c8e
  Serial number of failed request:  7495
  Current serial number in output stream:  7497

comment:8 by elexis, 9 years ago

sys_clipboard_get is implemented for each operating system individually - thats why the bug might not occur on osx.

lib/sysdep/os/win/wclipboard.cpp:wchar_t* sys_clipboard_get()
lib/sysdep/os/android/android.cpp:wchar_t* sys_clipboard_get()
lib/sysdep/os/unix/x/x.cpp:wchar_t *sys_clipboard_get()
lib/sysdep/os/osx/osx.cpp:wchar_t* sys_clipboard_get()

Here is a link to the file with the function sys_clipboard_get in line 177, that probably contains the bug: http://svn.wildfiregames.com/public/ps/trunk/source/lib/sysdep/os/unix/x/x.cpp

Notice that the application always reaches the "XGetWindowProperty succeeded, returning data" part, but with wrong data received by the XGetWindowProperty call the first time.

comment:9 by elexis, 9 years ago

A buddy using ubuntu 14 is experiencing the same bug.

comment:10 by temple, 7 years ago

Description: modified (diff)

Also on Ubuntu, experiencing the same bugs. When trying to copy something in the in-game chat window (rather than the lobby) the game almost always crashes.

comment:11 by elexis, 4 years ago

Milestone: BacklogAlpha 24
Patch: Phab:D2476
Summary: [Copy & Paste] need to paste two times to get correct contentsCopy & Paste need to paste two times to get correct contents

comment:12 by Stan, 4 years ago

Fixed in rP23624 (Tested on Kubuntu 20.04)

comment:13 by Stan, 4 years ago

Resolution: fixed
Status: newclosed
Note: See TracTickets for help on using tickets.