Tk Source Code

Check-in [2f691822]
Login

Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:Fix [382712ade6]: X11: 'event generate . <KeyPress>' segfaults. Patch from Christian Werner.
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | bug-382712ade6
Files: files | file ages | folders
SHA3-256: 2f691822db6cfab887afc6b02c99e9172ca7d72063bf0933f48e58d83eb1fffe
User & Date: fvogel 2018-01-10 20:45:24
Context
2018-01-18
14:23
Fix broken build (one line of the patch was missing) check-in: 8038fd23 user: fvogel tags: bug-382712ade6
2018-01-16
19:48
Fix [382712ade6]: X11: 'event generate . <KeyPress>' segfaults. Patch from Christian Werner. check-in: a0f74682 user: fvogel tags: core-8-6-branch
2018-01-10
20:45
Fix [382712ade6]: X11: 'event generate . <KeyPress>' segfaults. Patch from Christian Werner. check-in: 2f691822 user: fvogel tags: bug-382712ade6
2018-01-08
09:03
Some code cleanup, suggested by Christian Werner. Cherry-picked from bug-00a27923ee branch. check-in: 8acca87b user: jan.nijtmans tags: core-8-6-branch
Changes
Hide Diffs Unified Diffs Ignore Whitespace Patch

Changes to unix/tkUnixKey.c.

106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126


























127
128
129
130
131
132
133

const char *
TkpGetString(
    TkWindow *winPtr,		/* Window where event occurred */
    XEvent *eventPtr,		/* X keyboard event. */
    Tcl_DString *dsPtr)		/* Initialized, empty string to hold result. */
{
    int len;
    Tcl_DString buf;
    TkKeyEvent *kePtr = (TkKeyEvent *) eventPtr;

    /*
     * If we have the value cached already, use it now. [Bug 1373712]
     */

    if (kePtr->charValuePtr != NULL) {
	Tcl_DStringSetLength(dsPtr, kePtr->charValueLen);
	memcpy(Tcl_DStringValue(dsPtr), kePtr->charValuePtr,
		(unsigned) kePtr->charValueLen+1);
	return Tcl_DStringValue(dsPtr);
    }



























#ifdef TK_USE_INPUT_METHODS
    if ((winPtr->dispPtr->flags & TK_DISPLAY_USE_IM)
	    && (winPtr->inputContext != NULL)
	    && (eventPtr->type == KeyPress)) {
	Status status;








|













>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>
>







106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159

const char *
TkpGetString(
    TkWindow *winPtr,		/* Window where event occurred */
    XEvent *eventPtr,		/* X keyboard event. */
    Tcl_DString *dsPtr)		/* Initialized, empty string to hold result. */
{
    int len, mincode, maxcode;
    Tcl_DString buf;
    TkKeyEvent *kePtr = (TkKeyEvent *) eventPtr;

    /*
     * If we have the value cached already, use it now. [Bug 1373712]
     */

    if (kePtr->charValuePtr != NULL) {
	Tcl_DStringSetLength(dsPtr, kePtr->charValueLen);
	memcpy(Tcl_DStringValue(dsPtr), kePtr->charValuePtr,
		(unsigned) kePtr->charValueLen+1);
	return Tcl_DStringValue(dsPtr);
    }

    /*
     * Only do this for KeyPress events, otherwise
     * further Xlib function behavior might be undefined.
     */

    if (eventPtr->type != KeyPress) {
	len = 0;
	Tcl_DStringSetLength(dsPtr, len);
	goto done;
    }

    /*
     * Filter keycodes out of range, otherwise
     * further Xlib function behavior might be undefined.
     */

    mincode = 0;
    maxcode = -1;
    XDisplayKeycodes(winPtr->dispPtr->display, &mincode, &maxcode);
    if ((eventPtr->xkey.keycode < mincode) ||
	(eventPtr->xkey.keycode > maxcode)) {
	len = 0;
	Tcl_DStringSetLength(dsPtr, len);
	goto done;
    }

#ifdef TK_USE_INPUT_METHODS
    if ((winPtr->dispPtr->flags & TK_DISPLAY_USE_IM)
	    && (winPtr->inputContext != NULL)
	    && (eventPtr->type == KeyPress)) {
	Status status;