Tk Source Code

View Ticket
Login
Ticket UUID: 2443069
Title: Cannot replace [selection handle] command
Type: Bug Version: obsolete: 8.6b2
Submitter: andygoth Created on: 2008-12-17 23:21:22
Subsystem: 53. [selection] Assigned To: dkf
Priority: 5 Medium Severity: Minor
Status: Open Last Modified: 2024-07-09 21:03:37
Resolution: None Closed By: nobody
    Closed on: 2012-07-11 19:54:47
Description:
% package require Tk
% proc report {string args} {return $string}
% selection handle . {report 1}
% selection own .
% selection get
1
% selection get -type UTF8_STRING
1
% selection handle . {report 2}
% selection get
2
% selection get -type UTF8_STRING
1

When replacing the [selection handle] command, the automatically generated UTF8_STRING handler is *not* updated, only the STRING handler.  The attached patch fixes Tk_CreateSelHandler() to update both.  It also updates the Tk_CreateSelHandler() documentation to describe the automatic UTF8_STRING handler creation, updating, and removal.  I tested the patch successfully on X11.

Workaround 1: Use [selection handle -type UTF8_STRING] to explicitly set the UTF8_STRING handler in addition to the STRING handler.
Workaround 2: Use [selection handle $win ""] to clear the handler before changing it.
User Comments: fvogel added on 2024-07-09 21:03:37:

See also [af31a84c91].


andygoth added on 2012-08-31 21:34:22:
I got the core.tcl.tk account, but beyond that I've had no time to work on it.  I apologize.

nijtmans added on 2012-08-31 19:35:12:
Any progress on this?

dkf added on 2012-07-13 19:11:09:
(let me know via email; this doesn't belong in this bug report…)

dkf added on 2012-07-13 19:10:20:
I can set up the account easily. Andy, let me know what username you want and an email address and I'll get it sorted.

nijtmans added on 2012-07-13 14:26:12:
>ask him or a volunteer to test patches I write.
Andy,

My suggestion would be to get commit access on
core.tcl.tk (Donal, can you give that to Andy?) and
work on the bug-2443069 branch. Then anyone
can test/review your changes from there. I can
help you with merging it to trunk, after everything
is OK.

A test-case which reproduces the problem
discovered by Don (which crashes when
multiple handers have the same clientData),
would be the perfect way to prove
correctness of your upcoming fixes.

andygoth added on 2012-07-13 02:47:11:
I'll have a more detailed look tonight.  I currently lack access to a good development environment, so it may be a while before I can test any fixes.  dgp put a lot of good information in 3543050, so I might be able to go forward from there and ask him or a volunteer to test patches I write.

nijtmans added on 2012-07-13 01:46:18:
Bug 3543050 shows that the current patch is not ready to
be released yet. I don't want the 8.6b3 release
to be blocked because of that.

Andy, please have a look at this. I now reverted the change
from trunk, but it still is in the bug-2443069 branch.

(Donal, can you add andygoth to the tktoolkit project,
and assign this issue to him? That seems most logical)

nijtmans added on 2012-07-12 02:54:47:
Merging to trunk done now.

dkf added on 2012-07-10 19:11:49:
Whoops; meant to mention before that merging is the task that's left. :-)

nijtmans added on 2012-07-05 17:36:42:
Ping!

With everything sorted out, what's left to be
done, apart from merging this to trunk?

dkf added on 2012-07-02 16:28:01:

allow_comments - 0

dkf added on 2012-07-02 16:27:54:

IP - Comment Removed: 130.88.1.31

dkf added on 2012-07-02 16:26:07:

allow_comments - 1

Confirmed the fix; select.test passes cleanly on X11. (We have some odd old code in Tk.)

nijtmans added on 2012-07-01 18:04:24:
>And the minimal fix is to update the expected output to the real output;
I don't agree. It appears that switching the "selection handle"
command to the new synax (see bug #2441988) fixes the
bug as well, with the output as expected.

updated bug-2443069 to trunk now, which makes all
select/clipboard-related test pass.

To me it's OK to be merged to trunk, I'm convinced.

Donal?

dkf added on 2012-07-01 06:03:39:
And the minimal fix is to update the expected output to the real output; it's correct. We're just no longer throwing that information away completely and leaving bugs to fester.

OSX/Aqua has a *lot* more failing tests. Don't know the significance yet.

dkf added on 2012-07-01 05:56:39:
Digging with 'fossil annotate' indicates that the provenance of that weird [selection] syntax is "the mists of time"; it predates Tk's switch to CVS. In fact, it probably predates Tk 4.0, as I don't ever remember seeing that syntax documented *anywhere* in all the years I've used it. I also don't *think* it is mentioned in the 1st ed Ousterhout book; it's **OLD**.

I guess that:
   selection handle .f1 ERROR errHandler
is equivalent to:
   selection handle .f1 -type ERROR errHandler
(That is, it's the PRIMARY selection's ERROR target fetched in STRING wire format.)

dkf added on 2012-07-01 05:45:52:

IP - Comment Removed: 82.42.214.208

dkf added on 2012-07-01 05:34:18:
Tk doesn't get tested nearly as often as Tcl does, because it's entirely practical to do a run of Tcl's test suite in parallel with something else (only async.test is intrusive at all on this system). Tk's test suite is far less of a good neighbor (for good and obvious reasons). It's also too dependent on the fonts installed and the way the window manager behaves.

nijtmans added on 2012-06-27 04:14:33:
It turns out that test select-5.15 is already failing for
ages (why did no-one notice that before....). This
test was written to test for bug 2441988, so I
re-opened that one.
Conclusion: the failure of select-5.15 has nothing
to do with Andy's [selection handle] changes.

See:
    <http://core.tcl.tk/tk/info/bd1165a06d17b3df426b97cda3e7df675656a81e>

Donal, it appears that you know a lot more about
selection handles than I do. If you are OK with
merging this with trunk, I am as well. It's too
small to let it go though the TIP process.

andygoth added on 2012-06-20 21:53:12:
I don't understand it all that well, but it looks very fishy to me.  Take this line:

selection handle .f1 ERROR errHandler

The man page says:

selection handle ?-selection s? ?-type t? ?-format f? window command

I see no -selection, -type, or -format options, so .f1 is window and... well, what's ERROR supposed to be?  The intended command is [errHandler], since that generates the expected output string.  Maybe ERROR should be the value for the -type option, but that's a guess; wouldn't that also cause the result to *not* include an error about ERROR not being defined?  I'm not sure why this test ever worked, why my patch broke it, or what it's even trying to accomplish.

Some of the other tests contain this same [selection handle] line, though select-5.15 is the only one that tests for the "selection handler aborted" failure, so if this one line of code is faulty, it'll likely only matter for select-5.15.

nijtmans added on 2012-06-20 21:19:12:
After 10 days of silence, this doesn't look that high priority.

Andy? How do you think about the select-5.15 failure?

nijtmans added on 2012-06-11 01:40:36:
Donal, Thanks! I believe you. (personally, I never used the
selection function, so I don't consider myself an expert in this)

So, after doing what Donal suggests, there is one more
failure:
==== select-5.15 Tk_GetSelection procedure FAILED
==== Contents of test case:

    proc ::bgerror msg {lappend ::bgerrors $msg}
    selection handle .f1 ERROR errHandler
    list [catch {selection get ERROR} msg] $msg [update] {*}$::bgerrors

---- Result was:
1 {PRIMARY selection doesn't exist or form "ERROR" not defined} {}
---- Result should have been (exact matching):
1 {PRIMARY selection doesn't exist or form "ERROR" not defined} {} {selection handler aborted}
==== select-5.15 FAILED

What should be done about this one?

dkf added on 2012-06-09 23:37:19:
Those tests look like bystanders, with the thing tested for (equality of target list) being a proxy for what is interesting (TEST present in target list or not). Just update the expected test results. :-)

nijtmans added on 2012-06-09 14:33:45:
committed to branch bug-2443069

Looks good to me. The only problem with the
patch is that it causes two test failures (see below),
so those have to be fixed first before it can
be merged to trunk.

==== clipboard-5.1 Tk_ClipboardClear procedure FAILED
==== Contents of test case:

    clipboard append -t TEST "test"
    set result [lsort [clipboard get TARGETS]]
    clipboard clear
    list $result [lsort [clipboard get TARGETS]]

---- Result was:
{MULTIPLE TARGETS TEST TIMESTAMP TK_APPLICATION TK_WINDOW UTF8_STRING} {MULTIPLE TARGETS TIMESTAMP TK_APPLICATION TK_WINDOW UTF8_STRING}
---- Result should have been (exact matching):
{MULTIPLE TARGETS TEST TIMESTAMP TK_APPLICATION TK_WINDOW} {MULTIPLE TARGETS TIMESTAMP TK_APPLICATION TK_WINDOW}
==== clipboard-5.1 FAILED



==== clipboard-5.2 Tk_ClipboardClear procedure FAILED
==== Contents of test case:

    clipboard append -t TEST "test"
    set result [lsort [clipboard get TARGETS]]
    selection own -s CLIPBOARD .
    lappend result [lsort [clipboard get TARGETS]]
    clipboard clear
    clipboard append -t TEST "test"
    lappend result [lsort [clipboard get TARGETS]]

---- Result was:
MULTIPLE TARGETS TEST TIMESTAMP TK_APPLICATION TK_WINDOW UTF8_STRING {MULTIPLE TARGETS TIMESTAMP TK_APPLICATION TK_WINDOW} {MULTIPLE TARGETS TEST TIMESTAMP TK_APPLICATION TK_WINDOW UTF8_STRING}
---- Result should have been (exact matching):
MULTIPLE TARGETS TEST TIMESTAMP TK_APPLICATION TK_WINDOW {MULTIPLE TARGETS TIMESTAMP TK_APPLICATION TK_WINDOW} {MULTIPLE TARGETS TEST TIMESTAMP TK_APPLICATION TK_WINDOW}
==== clipboard-5.2 FAILED

andygoth added on 2012-06-09 06:12:02:
This has been hanging out for three to four years.  Please, somebody have a look at it.  I still need to manually apply this patch to get my application to work.

andygoth added on 2011-04-18 08:38:21:
I fixed some typos in the patch.

andygoth added on 2011-04-18 08:38:10:

File Added - 409062: tk-selectionutf8-v2.patch

dkf added on 2010-08-18 15:16:24:

IP - Comment Removed: 130.88.1.31

dkf added on 2010-08-18 15:16:19:

IP - Comment Removed: 130.88.1.31

dkf added on 2010-08-18 15:16:08:
It would be nice to be able to do this.

andygoth added on 2010-08-18 01:44:11:
Anybody home?

andygoth added on 2009-06-20 23:45:10:
bump

andygoth added on 2009-01-07 01:05:10:
Tiny amendment to the patch: Replace "but" with "that" in the line "existing STRING handler is also being replaced but has a different" in the patch for doc/CrtSelHdlr.3 .

andygoth added on 2008-12-18 06:21:22:

File Added - 305785: tk-selectionutf8.patch

Attachments: