Tk Source Code

View Ticket
Login
Ticket UUID: 459895
Title: Fix for directories that contain spaces
Type: Bug Version: None
Submitter: fandom Created on: 2001-09-09 01:38:49
Subsystem: 36. [tk_chooseDirectory] Assigned To: dkf
Priority: 5 Medium Severity:
Status: Closed Last Modified: 2001-09-17 21:14:16
Resolution: Fixed Closed By: dkf
    Closed on: 2001-09-17 14:14:16
Description:
As shipped with Tcl/Tk 8.4a3, tk_chooseDirectory in 
Unix won't enter into directory which names contain
spaces.
User Comments: dkf added on 2001-09-17 21:14:16:
Logged In: YES 
user_id=79902

Rewrote so as to remove the confusing variable name from all
related procedures.

nobody added on 2001-09-17 17:14:04:
Logged In: NO 

Looked briefly at the code in tkfbox.tcl and 
choosedir.tcl.  The main problem seems to be the code's use 
of 'text' as a really unhelpful variable name.  It's either 
a filename or a list of filenames and it would be best to 
clarify that by changing its name as appropriate.

The directory browsing culprit would appear to be:

proc ::tk::dialog::file::chooseDir::DblClick {w} {
    upvar ::tk::dialog::file::[winfo name $w] data
    set selection [tk::IconList_Curselection $data(icons)]
    if { [llength $selection] != 0 } {
set text [tk::IconList_Get $data(icons) [lindex 
$selection 0]]
set file $data(selectPath)
if {[file isdirectory $file]} {
    ::tk::dialog::file::ListInvoke $w $text
    return
}
    }
}    

a simple fix might be to replace $text with [list $text] 
there.  But I really think some renaming of 
variable/procedure names needs to happen to clarify what is 
going on in this code wrt lists vs files.

dgp added on 2001-09-15 11:41:45:
Logged In: YES 
user_id=80530

OK, it now appears to me that this is all just part of the
debugging of the new "-multiple" feature of the
[tk_get*File] commands in Tk 8.4.  Still examining to
determine the best fix.

dgp added on 2001-09-15 06:43:43:
Logged In: YES 
user_id=80530

Note that Tk 8.3.3 doesn't appear to suffer from
this bug, nor from Bug 220765.  It also does not
force treatment of the $text argument as a list,
which I think is a mistake.  It seems to me the
right solution is found in Tk 8.3.3.

dgp added on 2001-09-15 06:29:39:
Logged In: YES 
user_id=80530

Note that this bug was introduced by the bug fix
for Tk Bug 220765, contributed by Vince Darley.

Vince, if you read this comment, could you take
a look an comment on this issue?  I haven't yet
been able to determine if your patch was broken,
or merely incomplete.

fandom added on 2001-09-11 06:40:50:
Logged In: YES 
user_id=316500

The problem is that in tk::dialog::file::ListInvoke, the text
parameter is treated like this:

set file [::tk::dialog::file::JoinFile $data(selectPath) [lindex 
$text 0]]

So if the 'text' parameter contains spaces only the first word is 
taken.

As far as grep can see there is only one other place where this
procedure is invoked, this time for the tk_getOpenFile and 
tk_getSaveFile commands, this time the invocation is written:

::tk::dialog::file::ListInvoke $w [list $text]

On the other hand the invocation can be written

tk::dialog::file::ListInvoke $w "$text"

and we can do without the list command in ListInvoke, I have
also tried this and it also works, I don't really know which is the
best way though.

dgp added on 2001-09-11 04:27:21:
Logged In: YES 
user_id=80530

Hmmm... if this is a valid bug, then other calls
of tk::dialog::file::ListInvoke ought to be examined
for similar bad calls.  I see no documentation that
the argument "text" of tk::dialog::file::ListInvoke
will be treated as a list.  Perhaps the bug is really
elsewhere, and the submitted patch is merely a workaround?

fandom added on 2001-09-10 14:40:06:

File Added - 10577: patch

Logged In: YES 
user_id=316500

Here is the patch I should have send in the first place or,
at least, I hope this time I will manage to really send it.

dgp added on 2001-09-10 09:34:18:
Logged In: YES 
user_id=80530

There's no patch attached, so I'm assuming this is
a bug report.  Moving from Patches to Bugs.

Attachments: