4 From: Bram Moolenaar <Bram@moolenaar.net>
6 Content-Type: text/plain; charset=ISO-8859-1
7 Content-Transfer-Encoding: 8bit
11 Problem: strlen() used on text that may not end in a NUL. (Dominique Pelle)
12 Pasting a very big selection doesn't work.
13 Solution: Use the length passed to the XtSelectionCallbackProc() function.
14 After getting the SelectionNotify event continue dispatching
15 events until the callback is actually called. Also dispatch the
20 *** ../vim-7.2.016/src/ui.c Sun Sep 7 21:47:51 2008
21 --- src/ui.c Sun Sep 14 15:52:19 2008
25 if (value == NULL || *length == 0)
27 ! clip_free_selection(cbd); /* ??? [what's the query?] */
28 *(int *)success = FALSE;
33 if (value == NULL || *length == 0)
35 ! clip_free_selection(cbd); /* nothing received, clear register */
36 *(int *)success = FALSE;
41 text_prop.value = (unsigned char *)value;
42 text_prop.encoding = *type;
43 text_prop.format = *format;
44 ! text_prop.nitems = STRLEN(value);
45 status = XmbTextPropertyToTextList(X_DISPLAY, &text_prop,
47 if (status != Success || n_text < 1)
49 text_prop.value = (unsigned char *)value;
50 text_prop.encoding = *type;
51 text_prop.format = *format;
52 ! text_prop.nitems = len;
53 status = XmbTextPropertyToTextList(X_DISPLAY, &text_prop,
55 if (status != Success || n_text < 1)
58 case 3: type = text_atom; break;
59 default: type = XA_STRING;
62 XtGetSelectionValue(myShell, cbd->sel_atom, type,
63 clip_x11_request_selection_cb, (XtPointer)&success, CurrentTime);
66 case 3: type = text_atom; break;
67 default: type = XA_STRING;
70 XtGetSelectionValue(myShell, cbd->sel_atom, type,
71 clip_x11_request_selection_cb, (XtPointer)&success, CurrentTime);
75 * paste! Don't worry, we will catch up with any other events later.
77 start_time = time(NULL);
80 ! if (XCheckTypedEvent(dpy, SelectionNotify, &event))
82 ! /* this is where clip_x11_request_selection_cb() is actually
84 XtDispatchEvent(&event);
87 - if (XCheckTypedEvent(dpy, SelectionRequest, &event))
88 - /* We may get a SelectionRequest here and if we don't handle
89 - * it we hang. KDE klipper does this, for example. */
90 - XtDispatchEvent(&event);
92 /* Time out after 2 to 3 seconds to avoid that we hang when the
93 * other process doesn't respond. Note that the SelectionNotify
94 * event may still come later when the selection owner comes back
95 ! * to life and the text gets inserted unexpectedly (by xterm).
96 ! * Don't know how to avoid that :-(. */
97 if (time(NULL) > start_time + 2)
101 * paste! Don't worry, we will catch up with any other events later.
103 start_time = time(NULL);
104 ! while (success == MAYBE)
106 ! if (XCheckTypedEvent(dpy, SelectionNotify, &event)
107 ! || XCheckTypedEvent(dpy, SelectionRequest, &event)
108 ! || XCheckTypedEvent(dpy, PropertyNotify, &event))
110 ! /* This is where clip_x11_request_selection_cb() should be
111 ! * called. It may actually happen a bit later, so we loop
112 ! * until "success" changes.
113 ! * We may get a SelectionRequest here and if we don't handle
114 ! * it we hang. KDE klipper does this, for example.
115 ! * We need to handle a PropertyNotify for large selections. */
116 XtDispatchEvent(&event);
120 /* Time out after 2 to 3 seconds to avoid that we hang when the
121 * other process doesn't respond. Note that the SelectionNotify
122 * event may still come later when the selection owner comes back
123 ! * to life and the text gets inserted unexpectedly. Don't know
124 ! * why that happens or how to avoid that :-(. */
125 if (time(NULL) > start_time + 2)
136 /* don't do a retry with another type after timing out, otherwise we
141 ! if (success == TRUE)
144 /* don't do a retry with another type after timing out, otherwise we
145 *** ../vim-7.2.016/src/version.c Sun Sep 14 14:41:44 2008
146 --- src/version.c Sun Sep 14 15:55:34 2008
150 { /* Add new patch number below this line */
156 hundred-and-one symptoms of being an internet addict:
157 54. You start tilting your head sideways to smile. :-)
159 /// Bram Moolenaar -- Bram@Moolenaar.net -- http://www.Moolenaar.net \\\
160 /// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
161 \\\ download, build and distribute -- http://www.A-A-P.org ///
162 \\\ help me help AIDS victims -- http://ICCF-Holland.org ///