#13504: wxOSX-Cocoa bug handling non-ASCII file names
-----------------------------------------------------+----------------------
Reporter: andrewtrevorrow | Owner:
Type: defect | Status: new
Priority: normal | Milestone: 2.9.3
Component: wxOSX-Cocoa | Version: 2.9-svn
Keywords: regression wxString non-ASCII file name | Blockedby:
Patch: 0 | Blocking:
-----------------------------------------------------+----------------------
I've attached a modified version of the dnd sample code to make it easy to
see the bug. Replace dnd.cpp with my version, remake dnd.app, start it up
and then do these steps:
- Create a file (on the desktop is best) and give it a non-ASCII name by
typing something like option-A (å).
- Drag this file to the drop zone (upper left panel) in the dnd window.
This sets a global wxString called lastdrop.
- Now select Help > About to get a standard open file dialog and choose
the same file. This sets a global wxString called lastopen.
The log messages show that these two strings are NOT the same, even though
they look identical when displayed via wxLogStatus. In particular,
lastopen is 1 character longer than lastdrop, and if it is fprinted out to
the Console via
{{{
fprintf(stderr, "lastopen=%s\n", (const
char*)lastopen.mb_str(wxConvLocal));
}}}
the result is an empty string. This problem does not occur in wxMac
2.8.12. Any idea what is going wrong or how I might work around the
problem?
--
Ticket URL: <http://trac.wxwidgets.org/ticket/13504>
#13504: wxOSX-Cocoa bug handling non-ASCII file names
-----------------------------------------------------+----------------------
Reporter: andrewtrevorrow | Owner:
Type: defect | Status: new
Priority: normal | Milestone: 2.9.3
Component: wxOSX-Cocoa | Version: 2.9-svn
Keywords: regression wxString non-ASCII file name | Blockedby:
Patch: 0 | Blocking:
-----------------------------------------------------+----------------------
Comment(by vadz):
Without looking/testing, this is almost surely a normalization problem.
AFAIR OS X file system uses NFD while our string stuff probably uses NFC
(see http://en.wikipedia.org/wiki/Unicode_equivalence#Normal_forms).
Not sure what to do about this though... Using NFD is more logical in some
sense but working with NFC is simpler. So we probably should translate
file names to NFC.
Stefan, what do you think?
--
Ticket URL: <http://trac.wxwidgets.org/ticket/13504#comment:1>
#13504: wxOSX-Cocoa bug handling non-ASCII file names
-----------------------------------------------------+----------------------
Reporter: andrewtrevorrow | Owner:
Type: defect | Status: new
Priority: normal | Milestone: 2.9.3
Component: wxOSX-Cocoa | Version: 2.9-svn
Keywords: regression wxString non-ASCII file name | Blockedby:
Patch: 1 | Blocking:
-----------------------------------------------------+----------------------
Changes (by andrewtrevorrow):
* patch: 0 => 1
Comment:
Yes, it is a normalization problem. I've attached a patch that fixes
things, although probably not in the most sensible way. To avoid code
duplication it would probably be better to add a new routine in
src/common/filefn.cpp called wxNormalizePath or something similar.
Speaking of filefn.cpp, it looks like there might be memory leaks in
wxMacFSRefToPath and wxMacHFSUniStrToString. Both those routines create a
CFMutableStringRef by calling CFStringCreateMutableCopy but then fail to
call CFRelease. The last lines in both those routines should be replaced
by this code:
{{{
wxString result = wxCFStringRef(cfMutableString).AsString();
CFRelease(cfMutableString);
return result;
}}}
--
Ticket URL: <http://trac.wxwidgets.org/ticket/13504#comment:2>
#13504: wxOSX-Cocoa bug handling non-ASCII file names
-----------------------------------------------------+----------------------
Reporter: andrewtrevorrow | Owner: csomor
Type: defect | Status: accepted
Priority: normal | Milestone: 2.9.3
Component: wxOSX-Cocoa | Version: 2.9-svn
Keywords: regression wxString non-ASCII file name | Blockedby:
Patch: 1 | Blocking:
-----------------------------------------------------+----------------------
Changes (by csomor):
* owner: => csomor
* status: new => accepted
Comment:
I'll check this, we had once decided that within wx NFC should be used, so
apparently when going from Navigation Services to NSFilePanels I lost that
--
Ticket URL: <http://trac.wxwidgets.org/ticket/13504#comment:3>
#13504: wxOSX-Cocoa bug handling non-ASCII file names
-----------------------------------------------------+----------------------
Reporter: andrewtrevorrow | Owner: csomor
Type: defect | Status: accepted
Priority: normal | Milestone: 2.9.3
Component: wxOSX-Cocoa | Version: 2.9-svn
Keywords: regression wxString non-ASCII file name | Blockedby:
Patch: 1 | Blocking:
-----------------------------------------------------+----------------------
Comment(by csomor):
> Speaking of filefn.cpp, it looks like there might be memory leaks in
wxMacFSRefToPath and wxMacHFSUniStrToString. Both those routines create a
CFMutableStringRef by calling CFStringCreateMutableCopy but then fail to
call CFRelease. The last lines in both those routines should be replaced
by this code:
>
> {{{
> wxString result = wxCFStringRef(cfMutableString).AsString();
> CFRelease(cfMutableString);
> return result;
> }}}
wxCFStringRef is releasing cfMutableString in its destructor, did you
check the retain counts, am I overlooking an additional retain somewher
--
Ticket URL: <http://trac.wxwidgets.org/ticket/13504#comment:4>
#13504: wxOSX-Cocoa bug handling non-ASCII file names
-----------------------------------------------------+----------------------
Reporter: andrewtrevorrow | Owner: csomor
Type: defect | Status: accepted
Priority: normal | Milestone: 2.9.3
Component: wxOSX-Cocoa | Version: 2.9-svn
Keywords: regression wxString non-ASCII file name | Blockedby:
Patch: 1 | Blocking:
-----------------------------------------------------+----------------------
Comment(by andrewtrevorrow):
Replying to [comment:4 csomor]:
> wxCFStringRef is releasing cfMutableString in its destructor...
Ah, I hadn't noticed that. No leakage then.
--
Ticket URL: <http://trac.wxwidgets.org/ticket/13504#comment:5>
#13504: wxOSX-Cocoa bug handling non-ASCII file names
-----------------------------------------------------+----------------------
Reporter: andrewtrevorrow | Owner: csomor
Type: defect | Status: accepted
Priority: normal | Milestone: 2.9.3
Component: wxOSX-Cocoa | Version: 2.9-svn
Keywords: regression wxString non-ASCII file name | Blockedby:
Patch: 1 | Blocking:
-----------------------------------------------------+----------------------
Comment(by vadz):
We really should extract this in a reusable function (somewhere in
`include/wx/osx/core/private.h`?) instead of repeating the same code in 4
places (and maybe more in the future) but other than this it looks correct
to me.
Stefan, shouldn't we apply this for 2.9.3?
--
Ticket URL: <http://trac.wxwidgets.org/ticket/13504#comment:6>