#1583 tk_dialog can prevent user interaction

obsolete: 8.4.4
closed-fixed
9
2003-10-22
2003-10-21
No

On Windows XP, the following simple script:

tk_dialog .dial0 "test" [string repeat "hello there\n"
500] {} ok cancel

makes the dialog appear offscreen (at '901 -4946').
Given that none of the dialog is visible to the user at
all, the effect is a total application hang!

The problem appears to be caused here (in dialog.tcl):

update idletasks
set x [expr {[winfo screenwidth $w]/2 - [winfo
reqwidth $w]/2 \ - [winfo vrootx [winfo parent $w]]}]
set y [expr {[winfo screenheight $w]/2 - [winfo
reqheight $w]/2 \ - [winfo vrooty [winfo parent $w]]}]
wm geom $w +$x+$y
wm deiconify $w

For whatever reason 'winfo reqheight $w' is returning a
vast number like 11092 (which may well be correct
here). This number is then used to position the
dialog, but then the actual height of the dialog when
it appears is different (much smaller) and so when the
dialog appears it is totally offscreen (and then the
grab completes the lock-up).

The root of the bug appears to be elsewhere. I suggest
that at least for Tk 8.4.5 a test is put in dialog.tcl
so that huge dialogs don't go offscreen. Perhaps
something as simple as

if {$y < 0 && [winfo reqheight $w] > [winfo
screenheight $w]} { set y 0 }

Discussion

  • Donal K. Fellows

    • assigned_to: hobbs --> dkf
     
  • Donal K. Fellows

    • status: open --> closed-fixed
     
  • Donal K. Fellows

    Logged In: YES
    user_id=79902

    As it happens, you can unstick it by pressing the tab key (to
    make the focus sensibly on a button) and then the space key
    (to activate the button.) But this is *really* bad anyway!

    This is a really bizarre problem: why on earth would the
    actual size be less than the requested size in this case?

    Applied fixes (to 8.4 branch and HEAD) to generally constrain
    tk_dialog to be sensibly sized and placed.