View Issue Details

IDProjectCategoryView StatusLast Update
0034840LazarusLCLpublic2019-06-16 11:59
ReporterDavid Assigned ToJuha Manninen  
Status closedResolutionfixed 
Product Version2.0RC3 
Summary0034840: Unable to paste images when copied from another app
DescriptionIf an image is copied into the clipboard from another application, an app compiled with 20RC3 is unable to paste it into a TPicture. The reason appears to be that the 20RC3 app believes, incorrectly that there is no FormatIDs present in the clipboard.

This problem is not present in Lazarus 1.8.4 and does not show up in any release on Windows (not checked Mac yet).
Steps To ReproduceUsing the attached demo, build using 20RC3, you will be able to copy the Leopard image to the clipboard and then paste same image into TImage on the right. Press info button and see the apps view of FormatIDs available.

Now, copy an image form some other app, perhaps a webbrowser, right click, copy image. Return to the compiled app, you will be unable to paste it using Paste button, the Info button shows no FormatIDs available.

Additional InformationProblem confirmed by WP and confirmed OK on Windows by Bart, thanks !
TagsNo tags attached.
Fixed in Revisionr60131
WidgetsetGTK 2
Attached Files


related to 0018295 closedJuha Manninen Clipboard fails to get content 



2019-01-09 11:37

reporter (107,554 bytes)

Valdir Marcos

2019-01-09 17:33

reporter   ~0113289

This issue was discussed here:

Lazarus Release Candidate 3 for 2.0,43665.msg307403.html#msg307403

Bart Broersma

2019-01-09 23:11

developer   ~0113295

As discussed in the forum, this code fragment:

    else begin
         memo1.append('pasted as FormatID ' + inttostr(clipboard.FindPictureFormatID));

is wrong.


2019-01-15 07:51

reporter   ~0113421

Referring to discussion on forum, I pointed out that the problem still existed if the line -
is replaced by -

But that matters not, pasting, or attempting to paste is nothing to do with the problem. The problem is apparent long before pasting happens. An application queries the clipboard to see if it has content suitable for pasting. In Fixes_2_0 at present, the clipboard says it has no content if all it has is a picture.

Click the button labelled 'Info' to make such a request. If the image was copied into the clipboard from another app (ie clipboard cannot get to it via cache) you will see no formats listed.

I can (very easily) upload another demo with the alternative pasting model but, as I said, it really has nothing to do with the problem.


2019-01-15 07:53

reporter   ~0113422

Last edited: 2019-01-15 07:57

View 2 revisions

OK, problem seems to relate to changes made to /lcl/interfaces/gtk2/

function RequestSelectionData(ClipboardWidget: PGtkWidget;
  ClipboardType: TClipboardType; FormatID: PtrUInt): TGtkSelectionData;

about line number 7541 in 1.8.4 we have -
    if gtk_selection_convert(ClipboardWidget, ClipboardTypeAtoms[ClipboardType], FormatID, TimeID)<>GdkFalse
    then begin
      if not WaitForClipboardAnswer(c) then exit;

in Fixes_2_0 we have, at line number 7546
    if gtk_selection_convert(ClipboardWidget,Atom,FormatID,TimeID) <> GdkFalse then
      if gtk_clipboard_wait_is_text_available(gtk_clipboard_get(Atom)) then


I note the new code appears to depend on gtk_clipboard_wait_is_text_available() and the problem shows up when there is no text, only an image in the clipboard. Perhaps this function is unsuited to the application ?

Anyway, its clearly a deliberate change, something that needs be referred to whoever made the change. A patch from me reverting to old mode would clearly be unwelcome.


2019-01-20 12:54

reporter (107,262 bytes)


2019-01-20 12:56

reporter   ~0113519

Noting that the problem does not show up on the Mac, not surprising given my theory that its caused by gtk_clipboard_wait_is_text_available() !

I have uploaded a new test project in case anyone is still going on about the pasting code. Sigh.

jamie philbrook

2019-01-20 15:47

reporter   ~0113526

I don't know much about the gtk but maybe the line should of been like this

If gtk_clipBoard_wait_text_available(gtk_clipBoard_get(ClipboardTypeAtoms[ClipBoardType])) Then....

 or the "Atom" resolved prior to ?

 personally using a function with "TEXT" in it tells me that is all it's looking for but maybe that isn't the case here.

Bart Broersma

2019-01-20 22:29

developer   ~0113533

Revision 58969 breaks it.

Juha Manninen

2019-01-21 00:11

developer   ~0113538

> or the "Atom" resolved prior to ?

jamie, just look at the source and you know the answer.

> personally using a function with "TEXT" in it tells me that
> is all it's looking for but maybe that isn't the case here.

Apparently yes. How to fix it?

Juha Manninen

2019-01-21 13:08

developer   ~0113546

I think I figured it out myself. Please test with r60131.


2019-01-23 08:55

reporter   ~0113591

Just tested on Linux, both text and images reporting correctly and pasting fine.

This is all in Linux only code so no point in testing Windows/Mac ?

Thanks !


2019-06-16 11:59

reporter   ~0116750

All good.

Issue History

Date Modified Username Field Change
2019-01-09 11:37 David New Issue
2019-01-09 11:37 David File Added:
2019-01-09 17:33 Valdir Marcos Note Added: 0113289
2019-01-09 23:11 Bart Broersma Note Added: 0113295
2019-01-15 07:51 David Note Added: 0113421
2019-01-15 07:53 David Note Added: 0113422
2019-01-15 07:57 David Note Edited: 0113422 View Revisions
2019-01-20 12:54 David File Added:
2019-01-20 12:56 David Note Added: 0113519
2019-01-20 15:47 jamie philbrook Note Added: 0113526
2019-01-20 22:21 Bart Broersma LazTarget => -
2019-01-20 22:21 Bart Broersma Status new => acknowledged
2019-01-20 22:22 Bart Broersma Status acknowledged => confirmed
2019-01-20 22:28 Bart Broersma Assigned To => Juha Manninen
2019-01-20 22:28 Bart Broersma Status confirmed => assigned
2019-01-20 22:29 Bart Broersma Note Added: 0113533
2019-01-20 22:31 Bart Broersma Relationship added related to 0018295
2019-01-21 00:11 Juha Manninen Note Added: 0113538
2019-01-21 13:08 Juha Manninen Fixed in Revision => r60131
2019-01-21 13:08 Juha Manninen Note Added: 0113546
2019-01-21 13:08 Juha Manninen Status assigned => resolved
2019-01-21 13:08 Juha Manninen Resolution open => fixed
2019-01-23 08:55 David Note Added: 0113591
2019-06-16 11:59 David Status resolved => closed
2019-06-16 11:59 David Note Added: 0116750