applied SourceForge patch # 854330 for Filedialog Unicode fixes
git-svn-id: https://svn.wxwidgets.org/svn/wx/wxWidgets/trunk@24718 c3d73ce0-8a6f-49c7-b76d-6d57e0e08775
This commit is contained in:
@@ -360,9 +360,9 @@ int wxFileDialog::ShowModal()
|
|||||||
// tried using wxMacCFStringHolder in the code below, but it seems
|
// tried using wxMacCFStringHolder in the code below, but it seems
|
||||||
// the CFStrings were being released before the save dialog was called,
|
// the CFStrings were being released before the save dialog was called,
|
||||||
// causing a crash - open dialog works fine with or without wxMacCFStringHolder
|
// causing a crash - open dialog works fine with or without wxMacCFStringHolder
|
||||||
CFStringRef titleRef = ::CFStringCreateWithCString(NULL,
|
CFStringRef titleRef = ::CFStringCreateWithCharacters( kCFAllocatorDefault,
|
||||||
m_message.wc_str(),
|
(const unsigned short*)m_message.wc_str(),
|
||||||
kCFStringEncodingUnicode);
|
m_message.Len() );
|
||||||
#else
|
#else
|
||||||
CFStringRef titleRef = ::CFStringCreateWithCString(NULL,
|
CFStringRef titleRef = ::CFStringCreateWithCString(NULL,
|
||||||
m_message.c_str(),
|
m_message.c_str(),
|
||||||
@@ -370,9 +370,9 @@ int wxFileDialog::ShowModal()
|
|||||||
#endif
|
#endif
|
||||||
dialogCreateOptions.windowTitle = titleRef;
|
dialogCreateOptions.windowTitle = titleRef;
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
CFStringRef defaultFileNameRef = ::CFStringCreateWithCString(NULL,
|
CFStringRef defaultFileNameRef = ::CFStringCreateWithCharacters( kCFAllocatorDefault,
|
||||||
m_fileName.wc_str(),
|
(const unsigned short*)m_fileName.wc_str(),
|
||||||
kCFStringEncodingUnicode);
|
m_fileName.Len() );
|
||||||
#else
|
#else
|
||||||
CFStringRef defaultFileNameRef = ::CFStringCreateWithCString(NULL,
|
CFStringRef defaultFileNameRef = ::CFStringCreateWithCString(NULL,
|
||||||
m_fileName.c_str(),
|
m_fileName.c_str(),
|
||||||
@@ -459,8 +459,7 @@ int wxFileDialog::ShowModal()
|
|||||||
DescType actualType;
|
DescType actualType;
|
||||||
Size actualSize;
|
Size actualSize;
|
||||||
FSRef theFSRef;
|
FSRef theFSRef;
|
||||||
char thePath[FILENAME_MAX];
|
wxString thePath ;
|
||||||
|
|
||||||
long count;
|
long count;
|
||||||
::AECountItems(&navReply.selection , &count);
|
::AECountItems(&navReply.selection , &count);
|
||||||
for (long i = 1; i <= count; ++i)
|
for (long i = 1; i <= count; ++i)
|
||||||
@@ -472,7 +471,6 @@ int wxFileDialog::ShowModal()
|
|||||||
|
|
||||||
if (m_dialogStyle & wxSAVE)
|
if (m_dialogStyle & wxSAVE)
|
||||||
{
|
{
|
||||||
thePath[0] = '\0';
|
|
||||||
CFURLRef parentURLRef = ::CFURLCreateFromFSRef(NULL, &theFSRef);
|
CFURLRef parentURLRef = ::CFURLCreateFromFSRef(NULL, &theFSRef);
|
||||||
|
|
||||||
if (parentURLRef)
|
if (parentURLRef)
|
||||||
@@ -500,23 +498,23 @@ int wxFileDialog::ShowModal()
|
|||||||
|
|
||||||
if (cfStringUnescaped)
|
if (cfStringUnescaped)
|
||||||
{
|
{
|
||||||
|
Size len = CFStringGetLength( cfStringUnescaped ) ;
|
||||||
|
wxChar* buf = thePath.GetWriteBuf( len ) ;
|
||||||
|
//buf[0] = '\0';
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
::CFStringGetCString(cfStringUnescaped,
|
CFStringGetCharacters(cfStringUnescaped , CFRangeMake( 0 , len ) , (UniChar*) buf ) ;
|
||||||
thePath,
|
|
||||||
FILENAME_MAX,
|
|
||||||
kCFStringEncodingUnicode);
|
|
||||||
#else
|
#else
|
||||||
::CFStringGetCString(cfStringUnescaped,
|
CFStringGetCString( cfStringUnescaped , buf , len+1 , CFStringGetSystemEncoding() ) ;
|
||||||
thePath,
|
|
||||||
FILENAME_MAX,
|
|
||||||
CFStringGetSystemEncoding());
|
|
||||||
#endif
|
#endif
|
||||||
|
buf[len] = 0 ;
|
||||||
|
wxMacConvertNewlines10To13( buf ) ;
|
||||||
|
thePath.UngetWriteBuf() ;
|
||||||
::CFRelease(cfStringUnescaped);
|
::CFRelease(cfStringUnescaped);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!thePath[0])
|
if (!thePath)
|
||||||
{
|
{
|
||||||
::NavDisposeReply(&navReply);
|
::NavDisposeReply(&navReply);
|
||||||
return wxID_CANCEL;
|
return wxID_CANCEL;
|
||||||
@@ -524,8 +522,9 @@ int wxFileDialog::ShowModal()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
err = ::FSRefMakePath(&theFSRef,
|
const short maxpath = 1024 ;
|
||||||
(UInt8 *)thePath, sizeof(thePath));
|
::FSRefMakePath( &theFSRef , (UInt8*) thePath.GetWriteBuf(maxpath+1),maxpath) ;
|
||||||
|
thePath.UngetWriteBuf() ;
|
||||||
if (err != noErr)
|
if (err != noErr)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@@ -360,9 +360,9 @@ int wxFileDialog::ShowModal()
|
|||||||
// tried using wxMacCFStringHolder in the code below, but it seems
|
// tried using wxMacCFStringHolder in the code below, but it seems
|
||||||
// the CFStrings were being released before the save dialog was called,
|
// the CFStrings were being released before the save dialog was called,
|
||||||
// causing a crash - open dialog works fine with or without wxMacCFStringHolder
|
// causing a crash - open dialog works fine with or without wxMacCFStringHolder
|
||||||
CFStringRef titleRef = ::CFStringCreateWithCString(NULL,
|
CFStringRef titleRef = ::CFStringCreateWithCharacters( kCFAllocatorDefault,
|
||||||
m_message.wc_str(),
|
(const unsigned short*)m_message.wc_str(),
|
||||||
kCFStringEncodingUnicode);
|
m_message.Len() );
|
||||||
#else
|
#else
|
||||||
CFStringRef titleRef = ::CFStringCreateWithCString(NULL,
|
CFStringRef titleRef = ::CFStringCreateWithCString(NULL,
|
||||||
m_message.c_str(),
|
m_message.c_str(),
|
||||||
@@ -370,9 +370,9 @@ int wxFileDialog::ShowModal()
|
|||||||
#endif
|
#endif
|
||||||
dialogCreateOptions.windowTitle = titleRef;
|
dialogCreateOptions.windowTitle = titleRef;
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
CFStringRef defaultFileNameRef = ::CFStringCreateWithCString(NULL,
|
CFStringRef defaultFileNameRef = ::CFStringCreateWithCharacters( kCFAllocatorDefault,
|
||||||
m_fileName.wc_str(),
|
(const unsigned short*)m_fileName.wc_str(),
|
||||||
kCFStringEncodingUnicode);
|
m_fileName.Len() );
|
||||||
#else
|
#else
|
||||||
CFStringRef defaultFileNameRef = ::CFStringCreateWithCString(NULL,
|
CFStringRef defaultFileNameRef = ::CFStringCreateWithCString(NULL,
|
||||||
m_fileName.c_str(),
|
m_fileName.c_str(),
|
||||||
@@ -459,8 +459,7 @@ int wxFileDialog::ShowModal()
|
|||||||
DescType actualType;
|
DescType actualType;
|
||||||
Size actualSize;
|
Size actualSize;
|
||||||
FSRef theFSRef;
|
FSRef theFSRef;
|
||||||
char thePath[FILENAME_MAX];
|
wxString thePath ;
|
||||||
|
|
||||||
long count;
|
long count;
|
||||||
::AECountItems(&navReply.selection , &count);
|
::AECountItems(&navReply.selection , &count);
|
||||||
for (long i = 1; i <= count; ++i)
|
for (long i = 1; i <= count; ++i)
|
||||||
@@ -472,7 +471,6 @@ int wxFileDialog::ShowModal()
|
|||||||
|
|
||||||
if (m_dialogStyle & wxSAVE)
|
if (m_dialogStyle & wxSAVE)
|
||||||
{
|
{
|
||||||
thePath[0] = '\0';
|
|
||||||
CFURLRef parentURLRef = ::CFURLCreateFromFSRef(NULL, &theFSRef);
|
CFURLRef parentURLRef = ::CFURLCreateFromFSRef(NULL, &theFSRef);
|
||||||
|
|
||||||
if (parentURLRef)
|
if (parentURLRef)
|
||||||
@@ -500,23 +498,23 @@ int wxFileDialog::ShowModal()
|
|||||||
|
|
||||||
if (cfStringUnescaped)
|
if (cfStringUnescaped)
|
||||||
{
|
{
|
||||||
|
Size len = CFStringGetLength( cfStringUnescaped ) ;
|
||||||
|
wxChar* buf = thePath.GetWriteBuf( len ) ;
|
||||||
|
//buf[0] = '\0';
|
||||||
#if wxUSE_UNICODE
|
#if wxUSE_UNICODE
|
||||||
::CFStringGetCString(cfStringUnescaped,
|
CFStringGetCharacters(cfStringUnescaped , CFRangeMake( 0 , len ) , (UniChar*) buf ) ;
|
||||||
thePath,
|
|
||||||
FILENAME_MAX,
|
|
||||||
kCFStringEncodingUnicode);
|
|
||||||
#else
|
#else
|
||||||
::CFStringGetCString(cfStringUnescaped,
|
CFStringGetCString( cfStringUnescaped , buf , len+1 , CFStringGetSystemEncoding() ) ;
|
||||||
thePath,
|
|
||||||
FILENAME_MAX,
|
|
||||||
CFStringGetSystemEncoding());
|
|
||||||
#endif
|
#endif
|
||||||
|
buf[len] = 0 ;
|
||||||
|
wxMacConvertNewlines10To13( buf ) ;
|
||||||
|
thePath.UngetWriteBuf() ;
|
||||||
::CFRelease(cfStringUnescaped);
|
::CFRelease(cfStringUnescaped);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (!thePath[0])
|
if (!thePath)
|
||||||
{
|
{
|
||||||
::NavDisposeReply(&navReply);
|
::NavDisposeReply(&navReply);
|
||||||
return wxID_CANCEL;
|
return wxID_CANCEL;
|
||||||
@@ -524,8 +522,9 @@ int wxFileDialog::ShowModal()
|
|||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
err = ::FSRefMakePath(&theFSRef,
|
const short maxpath = 1024 ;
|
||||||
(UInt8 *)thePath, sizeof(thePath));
|
::FSRefMakePath( &theFSRef , (UInt8*) thePath.GetWriteBuf(maxpath+1),maxpath) ;
|
||||||
|
thePath.UngetWriteBuf() ;
|
||||||
if (err != noErr)
|
if (err != noErr)
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user