bugGNU Octave - Bugs: bug #62877, [octave-forge] (windows)...


bug #62877: [octave-forge] (windows) 'clipboard' function doesn't copy to cliboard

Submitter:  Philip Nienhuis <philipnienhuis>
Submitted:  Mon 08 Aug 2022 08:18:56 AM UTC
Category:  Octave Forge Package Severity:  3 - Normal
Priority:  5 - Normal Item Group:  Incorrect Result
Status:  Fixed Assigned to:  lostbard
Originator Name:  Philip Nienhuis Open/Closed:  * Closed
Release:  * other Operating System:  * Microsoft Windows
Fixed Release:  None Planned Release:  None
* Mandatory Fields

Add a New Comment (Rich Markup)

Comment Type & Canned Response:


( Jump to the original submission )

Thu 25 Aug 2022 06:11:19 PM UTC, comment #14: 

Thanks. For me it just works fine, so I'll close this bug report.
Yhanks for the fix.

Philip Nienhuis <philipnienhuis>
Project Member
Thu 25 Aug 2022 02:22:15 PM UTC, comment #13: 

new version of windows released with the change.

John Donoghue <lostbard>
Project Member
Tue 09 Aug 2022 05:26:06 PM UTC, comment #12: 

That Qt class might be a solution for copy/paste from a uitable (I posted about that in the Discourse maintainers forum).

Philip Nienhuis <philipnienhuis>
Project Member
Tue 09 Aug 2022 01:05:23 PM UTC, comment #11: 

QT provides a clipboard class:


I didnt use for the windows package  as in theory what I have should work even without the gui.

But it may be able to provide cross platform support

John Donoghue <lostbard>
Project Member
Tue 09 Aug 2022 01:00:27 PM UTC, comment #10: 
John Donoghue <lostbard>
Project Member
Mon 08 Aug 2022 09:40:41 PM UTC, comment #9: 

Sounds challenging :-)  but maybe it'll work. I suppose notepad would be the easiest candidate for it.
Maybe 'clipboard ("copy", ...)', run notepad, paste (if at all possible), let notepad write to temp file (COM/ActiveX? to avoid clobbering up the OS clipboard, we want to avoid that in the first place), read file back into Octave & compare.
And maybe the other way round for 'paste', although in my experience that works much more robust so maybe that's less needed.

In the mean time I've used the fixed clipboard() some more and it works wonderfully.
I've set status to "In Progress".

A little OT:
I'm wondering if this clipboard functionality could me made to work in Linux as well. AFAICS Ctrl-V and Ctrl-C work in many desktop environments OOTB so I guess there must have been some standardization.

Philip Nienhuis <philipnienhuis>
Project Member
Mon 08 Aug 2022 05:49:13 PM UTC, comment #8: 

Perhaps we can open notepad or something using COM (since we are using the windows package) and copy and paste with com (Im assuming possible) and verify it using the clipboard functions

John Donoghue <lostbard>
Project Member
Mon 08 Aug 2022 05:40:21 PM UTC, comment #7: 

Ni idea how to improve that.  => No idea how to improve that.

Philip Nienhuis <philipnienhuis>
Project Member
Mon 08 Aug 2022 05:39:38 PM UTC, comment #6: 

Yeah that fixes it.

But the test for clipboard ('copy', ...) isn't reliable, in the sense that it isn't able to do cross-application tests. Ni idea how to improve that.
Maybe at least a FIXME or so could be added there.

Philip Nienhuis <philipnienhuis>
Project Member
Mon 08 Aug 2022 05:38:06 PM UTC, comment #5: 

seems to work ok for win7, 32 bit, so will add to the windows package repo if it is also working for you

John Donoghue <lostbard>
Project Member
Mon 08 Aug 2022 05:20:19 PM UTC, comment #4: 

"more or less confirmed" that 'clipboard ("copy", ...)' only works with a pristine clipboard state, i.e. directly after login.
BTW I run (mostly) Windows 10.

That 'EmptyClipboard()' call looks to be the solution :-)
I'll try it and report back.

Philip Nienhuis <philipnienhuis>
Project Member
Mon 08 Aug 2022 03:56:01 PM UTC, comment #3: 

I think am seeing the same.

If I change the 'copy' if statement in clipboard.cc:

+ EmptyClipboard();
  SetClipboardData(CF_TEXT, hglb);

It seems to work ok in windows 11 at least.

John Donoghue <lostbard>
Project Member
Mon 08 Aug 2022 01:53:32 PM UTC, comment #2: 

Some more experimenting shows that copying to the clipboard functions very erratically. Maybe it only works the fist time? (clipboard not emptied before copying or so?)
Also, 'test clipboard' shows 'PASSES 3 out of 3 tests' but that's within the same program (Octave). My issue is that it doesn't work across different programs.

Philip Nienhuis <philipnienhuis>
Project Member
Mon 08 Aug 2022 11:24:33 AM UTC, comment #1: 

Just found out that at the office (where most IT stuff is locked down) it does work. Makes me wonder where to look to find out why it doesn't work elsewhere.
Let's leave this open until I had a chance to experiment and find out more.

Philip Nienhuis <philipnienhuis>
Project Member
Mon 08 Aug 2022 08:18:56 AM UTC, original submission:  

The 'clipboard' function in the windows package is only able to process strings, that's fine, but AFAICS doesn't want to copy to the clipboard. Pasting text (from the clipboard) works properly.

Steps to reproduce:

  • Make sure windows package 1.6.0 is loaded (1.5.0 doesn't seem to have 'clipboard')
  • Enter Octave command 'clipboard ("copy", "hello world")' # (w/o quotes, of course)
  • In some other program (Notepad? editor?) enter '<Ctrl-V' or invoke its 'paste' function
  • Result: no "hello world" pasted, rather nothing or some previous contents from elsewhere that was still on the clipboard.

I verified on the same box with Matlab (r2020b), there the clibboard function works as advertised.

Just FYI: I want to use this functionality as it seems the only way, or rather workaround, to copy/paste data from/to a uitable.

Package maintainer in cc.

Philip Nienhuis <philipnienhuis>
Project Member


(Note: upload size limit is set to 16384 kB, after insertion of the required escape characters.)

Attach Files:

No files currently attached


Depends on the following items: None found

Items that depend on this one: None found


Carbon-Copy List
  • -email is unavailable- added by lostbard (Posted a comment)
  • -email is unavailable- added by philipnienhuis (Submitted the item)
  • -email is unavailable- added by philipnienhuis

    There are 0 votes so far. Votes easily highlight which items people would like to see resolved in priority, independently of the priority of the item set by tracker managers.

    Only project members can vote.





    Follow 7 latest changes.

    Date Changed by Updated Field Previous Value => Replaced by
    2022-08-25 philipnienhuis StatusReady For Test Fixed
        Open/ClosedOpen Closed
    2022-08-09 lostbard StatusNone Ready For Test
        Assigned toNone lostbard
    2022-08-09 lostbard StatusIn Progress None
    2022-08-08 philipnienhuis StatusNone In Progress
    2022-08-08 philipnienhuis Carbon-Copy- Added lostbard

    Back to the top

    Powered by Savane 3.9