Skip to content

Commit

Permalink
Fix [fdc0ed342d]: Segfault on focus -force with xvfb.
Browse files Browse the repository at this point in the history
  • Loading branch information
fvogelnew1 committed Mar 19, 2024
2 parents a2d776d + 29c3ce9 commit 2a8bde2
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 2 deletions.
5 changes: 3 additions & 2 deletions generic/tkFocus.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ typedef struct TkDisplayFocusInfo {

#define DEBUG(dispPtr, arguments) \
if ((dispPtr)->focusDebug) { \
printf arguments; \
printf arguments; fflush(stdout); \
}

/*
Expand Down Expand Up @@ -501,12 +501,13 @@ TkFocusFilterEvent(

if ((dispPtr->implicitWinPtr != NULL)
&& !(winPtr->flags & TK_EMBEDDED)) {
DEBUG(dispPtr, ("Defocussed implicit Async\n"));
DEBUG(dispPtr, ("Defocussed implicit Async from %s\n", displayFocusPtr->focusWinPtr->pathName));
GenerateFocusEvents(displayFocusPtr->focusWinPtr, NULL);
XSetInputFocus(dispPtr->display, PointerRoot, RevertToPointerRoot,
CurrentTime);
displayFocusPtr->focusWinPtr = NULL;
dispPtr->implicitWinPtr = NULL;
dispPtr->focusPtr = NULL;
}
}
return retValue;
Expand Down
23 changes: 23 additions & 0 deletions tests/focus.test
Original file line number Diff line number Diff line change
Expand Up @@ -755,6 +755,29 @@ test focus-7.1 {TkSetFocusWin procedure, unmapped windows} -setup {
destroy .top
} -result {.top.s3}

test focus-8.1 {fdc0ed342d - segfault on focus -force} -body {
pack [button .b0]
toplevel .one
update
event generate .one <Motion> -warp 1 -x 175 -y 175
update idletasks
destroy {*}[winfo children .]
toplevel .t
pack [canvas .t.c]
update
destroy .t.c
pack [label .t.l]
update
destroy .t.l
destroy {*}[winfo children .]
proc crashit {} {
pack [listbox .l]
update
focus -force .l; # This line segfaulted *with xvfb*
set res Reached
}
crashit
} -result {Reached}

deleteWindows

Expand Down

0 comments on commit 2a8bde2

Please sign in to comment.