X-Git-Url: https://git.saurik.com/wxWidgets.git/blobdiff_plain/a9412f8f03171fdd3606a4ad3db9c9da8fe6bd7c..fadb227e012ef07927f8548b9753b42dcc13b700:/src/mac/carbon/filedlg.cpp diff --git a/src/mac/carbon/filedlg.cpp b/src/mac/carbon/filedlg.cpp index 677a77151e..08bce85f1f 100644 --- a/src/mac/carbon/filedlg.cpp +++ b/src/mac/carbon/filedlg.cpp @@ -322,10 +322,20 @@ pascal Boolean CrossPlatformFilterCallback ( { FSRef fsref ; memcpy( &fsref , *theItem->dataHandle , sizeof(FSRef) ) ; - wxString file ; - const short maxpath = 1024 ; - FSRefMakePath( &fsref , (UInt8*) file.GetWriteBuf(maxpath+1),maxpath) ; - file.UngetWriteBuf() ; + + + + CFURLRef fullURLRef; + fullURLRef = ::CFURLCreateFromFSRef(NULL, &fsref); +#ifdef __UNIX__ + CFURLPathStyle pathstyle = kCFURLPOSIXPathStyle; +#else + CFURLPathStyle pathstyle = kCFURLHFSPathStyle; +#endif + CFStringRef cfString = CFURLCopyFileSystemPath(fullURLRef, pathstyle); + ::CFRelease( fullURLRef ) ; + wxString file = wxMacCFStringHolder(cfString).AsString(wxFont::GetDefaultEncoding()); + display = CheckFile( file , theInfo->fileAndFolder.fileInfo.finderInfo.fdType , data ) ; } #endif @@ -346,29 +356,13 @@ int wxFileDialog::ShowModal() // this was always unset in the old code dialogCreateOptions.optionFlags &= ~kNavSelectDefaultLocation; -#if wxUSE_UNICODE - // tried using wxMacCFStringHolder in the code below, but it seems - // the CFStrings were being released before the save dialog was called, - // causing a crash - open dialog works fine with or without wxMacCFStringHolder - CFStringRef titleRef = ::CFStringCreateWithCharacters( kCFAllocatorDefault, - (const unsigned short*)m_message.wc_str(), - m_message.Len() ); -#else - CFStringRef titleRef = ::CFStringCreateWithCString(NULL, - m_message.c_str(), - m_font.GetEncoding() ); -#endif - dialogCreateOptions.windowTitle = titleRef; -#if wxUSE_UNICODE - CFStringRef defaultFileNameRef = ::CFStringCreateWithCharacters( kCFAllocatorDefault, - (const unsigned short*)m_fileName.wc_str(), - m_fileName.Len() ); -#else - CFStringRef defaultFileNameRef = ::CFStringCreateWithCString(NULL, - m_fileName.c_str(), - m_font.GetEncoding()); -#endif - dialogCreateOptions.saveFileName = defaultFileNameRef; + wxMacCFStringHolder message(m_message, m_font.GetEncoding()); + dialogCreateOptions.windowTitle = message; + + wxMacCFStringHolder defaultFileName(m_fileName, m_font.GetEncoding()); + dialogCreateOptions.saveFileName = defaultFileName; + + NavDialogRef dialog; NavObjectFilterUPP navFilterUPP = NULL; CFArrayRef cfArray = NULL; // for popupExtension @@ -424,20 +418,8 @@ int wxFileDialog::ShowModal() if (navFilterUPP) ::DisposeNavObjectFilterUPP(navFilterUPP); if (cfArray) - { - CFIndex n = ::CFArrayGetCount(cfArray); - for (CFIndex i = 0; i < n; i++) - { - CFStringRef str = (CFStringRef) ::CFArrayGetValueAtIndex(cfArray, i); - if (str) - ::CFRelease(str); - } ::CFRelease(cfArray); - } - if (titleRef) - ::CFRelease(titleRef); - if (defaultFileNameRef) - ::CFRelease(defaultFileNameRef); + if (err != noErr) return wxID_CANCEL;