summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorfvogel <fvogelnew1@free.fr>2017-11-19 20:50:14 (GMT)
committerfvogel <fvogelnew1@free.fr>2017-11-19 20:50:14 (GMT)
commit1be013d5076a48c72c60f3c611335cc787004b4e (patch)
tree5b0f3bb057bc8e73e76c030dcfeb3d63783754f5
parent453c86e0e9f9fce7d9d0149e09f2b1bb2040a846 (diff)
parentb8aaeefe598d7cbcbfb19d8ffc906f107d946428 (diff)
downloadtk-1be013d5076a48c72c60f3c611335cc787004b4e.zip
tk-1be013d5076a48c72c60f3c611335cc787004b4e.tar.gz
tk-1be013d5076a48c72c60f3c611335cc787004b4e.tar.bz2
Fix [73ba07efcd]: Use correct property type when handling MULTIPLE conversion requests. Patch from 'dpb'
-rw-r--r--generic/tkInt.h1
-rw-r--r--generic/tkSelect.c1
-rw-r--r--tests/select.test23
-rw-r--r--unix/tkUnixSelect.c9
4 files changed, 29 insertions, 5 deletions
diff --git a/generic/tkInt.h b/generic/tkInt.h
index a28cae4..4b5aebb 100644
--- a/generic/tkInt.h
+++ b/generic/tkInt.h
@@ -423,6 +423,7 @@ typedef struct TkDisplay {
Atom windowAtom; /* Atom for TK_WINDOW. */
Atom clipboardAtom; /* Atom for CLIPBOARD. */
Atom utf8Atom; /* Atom for UTF8_STRING. */
+ Atom atomPairAtom; /* Atom for ATOM_PAIR. */
Tk_Window clipWindow; /* Window used for clipboard ownership and to
* retrieve selections between processes. NULL
diff --git a/generic/tkSelect.c b/generic/tkSelect.c
index d763411..fcfd323 100644
--- a/generic/tkSelect.c
+++ b/generic/tkSelect.c
@@ -1185,6 +1185,7 @@ TkSelInit(
dispPtr->applicationAtom = Tk_InternAtom(tkwin, "TK_APPLICATION");
dispPtr->windowAtom = Tk_InternAtom(tkwin, "TK_WINDOW");
dispPtr->clipboardAtom = Tk_InternAtom(tkwin, "CLIPBOARD");
+ dispPtr->atomPairAtom = Tk_InternAtom(tkwin, "ATOM_PAIR");
/*
* Using UTF8_STRING instead of the XA_UTF8_STRING macro allows us to
diff --git a/tests/select.test b/tests/select.test
index 77bfb2e..a7cd780 100644
--- a/tests/select.test
+++ b/tests/select.test
@@ -17,6 +17,13 @@ namespace import ::tk::test:loadTkCommand
eval tcltest::configure $argv
tcltest::loadTestedCommands
+testConstraint cliboardManagerPresent 0
+if {![catch {selection get -selection CLIPBOARD_MANAGER -type TARGETS}]} {
+ if {"SAVE_TARGETS" in [selection get -selection CLIPBOARD_MANAGER -type TARGETS]} {
+ testConstraint cliboardManagerPresent 1
+ }
+}
+
global longValue selValue selInfo
set selValue {}
@@ -1044,6 +1051,8 @@ test select-10.6 {ConvertSelection procedure, reentrancy issues} -constraints {
lappend result [dobg {selection get}]
cleanupbg
lappend result $selInfo
+} -cleanup {
+ rename weirdHandler {}
} -result {{PRIMARY selection doesn't exist or form "STRING" not defined} {STRING 0 4000}}
##############################################################################
@@ -1148,8 +1157,20 @@ test select-13.1 {SelectionSize procedure, handler deleted} -constraints {
cleanupbg
lappend result $selInfo
} -result {{PRIMARY selection doesn't exist or form "STRING" not defined} {.f1 STRING 0 4000 .f1 STRING 4000 4000}}
+
+test select-14.1 {Bug [73ba07efcd]: Use correct property type when handling MULTIPLE conversion requests} -constraints {
+ cliboardManagerPresent
+} -setup {
+ proc get_clip {offset maxChars} {return abcd}
+} -body {
+ selection handle -selection CLIPBOARD . get_clip
+ selection own -selection CLIPBOARD .
+ selection get -selection CLIPBOARD_MANAGER -type SAVE_TARGETS
+ clipboard get
+} -cleanup {
+ rename get_clip {}
+} -result {abcd}
-catch {rename weirdHandler {}}
# cleanup
cleanupTests
diff --git a/unix/tkUnixSelect.c b/unix/tkUnixSelect.c
index dacbd99..6d379ec 100644
--- a/unix/tkUnixSelect.c
+++ b/unix/tkUnixSelect.c
@@ -872,8 +872,9 @@ ConvertSelection(
goto refuse;
}
result = XGetWindowProperty(eventPtr->display, eventPtr->requestor,
- eventPtr->property, 0, MAX_PROP_WORDS, False, XA_ATOM,
- &type, &format, &incr.numConversions, &bytesAfter,
+ eventPtr->property, 0, MAX_PROP_WORDS, False,
+ winPtr->dispPtr->atomPairAtom, &type, &format,
+ &incr.numConversions, &bytesAfter,
(unsigned char **) multAtomsPtr);
if ((result != Success) || (bytesAfter != 0) || (format != 32)
|| (type == None)) {
@@ -1035,8 +1036,8 @@ ConvertSelection(
}
if (multiple) {
XChangeProperty(reply.xsel.display, reply.xsel.requestor,
- reply.xsel.property, XA_ATOM, 32, PropModeReplace,
- (unsigned char *) incr.multAtoms,
+ reply.xsel.property, winPtr->dispPtr->atomPairAtom,
+ 32, PropModeReplace, (unsigned char *) incr.multAtoms,
(int) incr.numConversions*2);
} else {
/*