Skip to content

Commit 9513b4f

Browse files
committed
Rename variable "tk_dialog" to "testDialog" (namespace ::tk::test::dialog). It's a better name and it prevents confusion with the Tk command tk_dialog.
1 parent a5d35d1 commit 9513b4f

File tree

5 files changed

+36
-35
lines changed

5 files changed

+36
-35
lines changed

library/fontchooser.tcl

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -172,7 +172,7 @@ proc ::tk::fontchooser::Create {} {
172172
if {![winfo exists $S(W)]} {
173173
toplevel $S(W) -class TkFontDialog
174174
if {[package provide tcltest] ne {}} {
175-
set ::tk::test::dialog::tk_dialog $S(W)
175+
set ::tk::test::dialog::testDialog $S(W)
176176
}
177177
wm withdraw $S(W)
178178
wm title $S(W) $S(-title)

tests/fontchooser.test

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,15 +8,15 @@ tcltest::loadTestedCommands
88

99
# Import utility procs for specific functional areas
1010
namespace import -force ::tk::test::dialog::*
11-
upvar #0 ::tk::test::dialog::tk_dialog tk_dialog
11+
upvar #0 ::tk::test::dialog::testDialog testDialog
1212
set applyFontCmd [list testDialogFont set]
1313

1414
proc Click {button} {
15-
upvar #0 ::tk::test::dialog::tk_dialog tk_dialog
15+
upvar #0 ::tk::test::dialog::testDialog testDialog
1616
switch -exact -- $button {
17-
ok { $tk_dialog.ok invoke }
18-
cancel { $tk_dialog.cancel invoke }
19-
apply { $tk_dialog.apply invoke }
17+
ok { $testDialog.ok invoke }
18+
cancel { $testDialog.cancel invoke }
19+
apply { $testDialog.apply invoke }
2020
default { return -code error "invalid button name \"$button\"" }
2121
}
2222
}
@@ -74,7 +74,7 @@ test fontchooser-2.0 {fontchooser -title} -constraints scriptImpl -body {
7474
tk::fontchooser::Show
7575
}
7676
testDialog onDisplay {
77-
set x [wm title $tk_dialog]
77+
set x [wm title $testDialog]
7878
Click cancel
7979
}
8080
set x
@@ -87,7 +87,7 @@ test fontchooser-2.1 {fontchooser -title (cyrillic)} -constraints scriptImpl -bo
8787
tk::fontchooser::Show
8888
}
8989
testDialog onDisplay {
90-
set x [wm title $tk_dialog]
90+
set x [wm title $testDialog]
9191
Click cancel
9292
}
9393
set x
@@ -99,7 +99,7 @@ test fontchooser-3.0 {fontchooser -parent} -constraints scriptImpl -body {
9999
tk::fontchooser::Show
100100
}
101101
testDialog onDisplay {
102-
set x [winfo parent $tk_dialog]
102+
set x [winfo parent $testDialog]
103103
Click cancel
104104
}
105105
set x

tests/testutils.tcl

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -458,13 +458,13 @@ namespace eval ::tk::test::dialog {
458458
variable testDialogResult
459459
variable testDialogFont
460460
variable iter_after
461-
variable tk_dialog; # On MS Windows, this variable is set at the C level
461+
variable testDialog; # On MS Windows, this variable is set at the C level
462462
# by SetTkDialog() in tkWinDialog.c
463463

464464
switch -- $stage {
465465
launch {
466466
set iter_after 0
467-
set tk_dialog {}
467+
set testDialog {}
468468
if {$::tcl_platform(platform) eq "windows"} {
469469
variable testDialogClass "#32770"
470470
}
@@ -490,19 +490,20 @@ namespace eval ::tk::test::dialog {
490490
set doRepeat 0
491491

492492
if {$::tcl_platform(platform) eq "windows"} {
493-
# On Vista and later, using the new file dialogs we have to find
494-
# the window using its title as tk_dialog will not be set at the C level
493+
# On Vista and later, using the new file dialogs we have to
494+
# find the window using its title as testDialog will not be
495+
# set at the C level.
495496
variable testDialogClass
496-
if {[catch {testfindwindow "" $testDialogClass} tk_dialog]} {
497+
if {[catch {testfindwindow "" $testDialogClass} testDialog]} {
497498
set doRepeat 1
498499
}
499-
} elseif {$tk_dialog eq ""} {
500+
} elseif {$testDialog eq ""} {
500501
set doRepeat 1
501502
}
502503

503504
if {$doRepeat} {
504505
if {[incr iter_after] > 30} {
505-
set testDialogResult ">30 iterations waiting for tk_dialog"
506+
set testDialogResult ">30 iterations waiting for testDialog"
506507
return
507508
}
508509
after 150 [list ::tk::test::dialog::testDialog onDisplay2]

tests/winDialog.test

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ tcltest::loadTestedCommands
1414

1515
# Import utility procs for specific functional areas
1616
namespace import -force ::tk::test::dialog::*
17-
upvar #0 ::tk::test::dialog::tk_dialog tk_dialog
17+
upvar #0 ::tk::test::dialog::testDialog testDialog
1818
set applyFontCmd [list testDialogFont set]
1919

2020
if {[testConstraint testwinevent]} {
@@ -32,27 +32,27 @@ testConstraint english [expr {
3232
set initialDir [tcltest::temporaryDirectory]
3333

3434
proc Click {button} {
35-
upvar #0 ::tk::test::dialog::tk_dialog tk_dialog
35+
upvar #0 ::tk::test::dialog::testDialog testDialog
3636
switch -exact -- $button {
3737
ok { set button 1 }
3838
cancel { set button 2 }
3939
}
40-
testwinevent $tk_dialog $button WM_LBUTTONDOWN 1 0x000a000b
41-
testwinevent $tk_dialog $button WM_LBUTTONUP 0 0x000a000b
40+
testwinevent $testDialog $button WM_LBUTTONDOWN 1 0x000a000b
41+
testwinevent $testDialog $button WM_LBUTTONUP 0 0x000a000b
4242
}
4343

4444
proc GetText {id} {
45-
upvar #0 ::tk::test::dialog::tk_dialog tk_dialog
45+
upvar #0 ::tk::test::dialog::testDialog testDialog
4646
switch -exact -- $id {
4747
ok { set id 1 }
4848
cancel { set id 2 }
4949
}
50-
return [testwinevent $tk_dialog $id WM_GETTEXT]
50+
return [testwinevent $testDialog $id WM_GETTEXT]
5151
}
5252

5353
proc SetText {id text} {
54-
upvar #0 ::tk::test::dialog::tk_dialog tk_dialog
55-
return [testwinevent $tk_dialog $id WM_SETTEXT $text]
54+
upvar #0 ::tk::test::dialog::testDialog testDialog
55+
return [testwinevent $testDialog $id WM_SETTEXT $text]
5656
}
5757

5858
# ----------------------------------------------------------------------
@@ -92,7 +92,7 @@ test winDialog-1.4 {Tk_ChooseColorObjCmd: -title} -constraints {
9292
testDialog launch {set clr [tk_chooseColor -initialcolor "#ff9933" -title "Hello"]}
9393
testDialog onDisplay {
9494
if {[catch {
95-
array set a [testgetwindowinfo $tk_dialog]
95+
array set a [testgetwindowinfo $testDialog]
9696
if {[info exists a(text)]} {lappend x $a(text)}
9797
} err]} { lappend x $err }
9898
lappend x [Click ok]
@@ -111,7 +111,7 @@ test winDialog-1.5 {Tk_ChooseColorObjCmd: -title} -constraints {
111111
}
112112
testDialog onDisplay {
113113
if {[catch {
114-
array set a [testgetwindowinfo $tk_dialog]
114+
array set a [testgetwindowinfo $testDialog]
115115
if {[info exists a(text)]} {lappend x $a(text)}
116116
} err]} { lappend x $err }
117117
lappend x [Click ok]
@@ -127,7 +127,7 @@ test winDialog-1.6 {Tk_ChooseColorObjCmd: -parent} -constraints {
127127
set x {}
128128
testDialog onDisplay {
129129
if {[catch {
130-
array set a [testgetwindowinfo $tk_dialog]
130+
array set a [testgetwindowinfo $testDialog]
131131
if {[info exists a(parent)]} {
132132
append x [expr {$a(parent) == [wm frame .]}]
133133
}
@@ -912,7 +912,7 @@ test winDialog-10.5 {Tk_FontchooserObjCmd: -parent} -constraints {
912912
tk fontchooser show
913913
}
914914
testDialog onDisplay {
915-
array set a [testgetwindowinfo $tk_dialog]
915+
array set a [testgetwindowinfo $testDialog]
916916
Click cancel
917917
}
918918
list [expr {$a(parent) == [wm frame .]}] [testDialogFont get]
@@ -950,7 +950,7 @@ test winDialog-10.8 {Tk_FontchooserObjCmd: -title} -constraints {
950950
tk fontchooser show
951951
}
952952
testDialog onDisplay {
953-
array set a [testgetwindowinfo $tk_dialog]
953+
array set a [testgetwindowinfo $testDialog]
954954
Click cancel
955955
}
956956
set a(text)
@@ -966,7 +966,7 @@ test winDialog-10.9 {Tk_FontchooserObjCmd: -title} -constraints {
966966
tk fontchooser show
967967
}
968968
testDialog onDisplay {
969-
array set a [testgetwindowinfo $tk_dialog]
969+
array set a [testgetwindowinfo $testDialog]
970970
Click cancel
971971
}
972972
set a(text)

win/tkWinDialog.c

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -154,7 +154,7 @@ typedef struct {
154154
typedef struct OFNData {
155155
Tcl_Interp *interp; /* Interp, used only if debug is turned on,
156156
* for setting the variable
157-
* "::tk::test::dialog::tk_dialog". */
157+
* "::tk::test::dialog::testDialog". */
158158
int dynFileBufferSize; /* Dynamic filename buffer size, stored to
159159
* avoid shrinking and expanding the buffer
160160
* when selection changes */
@@ -647,7 +647,7 @@ EatSpuriousMessageBugFix(void)
647647
* TkWinDialogDebug --
648648
*
649649
* Function to turn on/off debugging support for common dialogs under
650-
* windows. The variable "::tk::test::dialog::tk_dialog" is set to the
650+
* windows. The variable "::tk::test::dialog::testDialog" is set to the
651651
* identifier of the dialog window when the modal dialog window pops up
652652
* and it is safe to send messages to the dialog.
653653
*
@@ -1841,7 +1841,7 @@ GetFileName(
18411841
* OFNHookProc --
18421842
*
18431843
* Dialog box hook function. This is used to set the variable
1844-
* "::tk::test::dialog::tk_dialog" for test/debugging when the dialog
1844+
* "::tk::test::dialog::testDialog" for test/debugging when the dialog
18451845
* is ready to receive messages. When multiple file selection is enabled
18461846
* this function is used to process the list of names.
18471847
*
@@ -2951,7 +2951,7 @@ MsgBoxCBTProc(
29512951
* SetTkDialog --
29522952
*
29532953
* Records the HWND for a native dialog in the variable
2954-
* ":tk::test::dialog::tk_dialog" so that the test-suite can operate
2954+
* ":tk::test::dialog::testDialog" so that the test-suite can operate
29552955
* on the correct dialog window. Use of this is enabled when a test
29562956
* program calls TkWinDialogDebug by calling the test command
29572957
* 'testwinevent debug 1'.
@@ -2968,7 +2968,7 @@ SetTkDialog(
29682968
char buf[32];
29692969

29702970
snprintf(buf, sizeof(buf), "0x%" TCL_Z_MODIFIER "x", (size_t)clientData);
2971-
Tcl_SetVar2(tsdPtr->debugInterp, "::tk::test::dialog::tk_dialog", NULL,
2971+
Tcl_SetVar2(tsdPtr->debugInterp, "::tk::test::dialog::testDialog", NULL,
29722972
buf, TCL_GLOBAL_ONLY);
29732973
}
29742974

0 commit comments

Comments
 (0)