From: Ippei U. <ip...@us...> - 2005-05-15 14:03:18
|
Update of /cvsroot/hugin/hugin/src/hugin In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv22560 Modified Files: MainFrame.cpp AutoCtrlPointCreator.cpp huginApp.cpp Log Message: Mac: changed application bundle code with wxMacCFStringHolder hack so that the path can contain unicode characters. Index: AutoCtrlPointCreator.cpp =================================================================== RCS file: /cvsroot/hugin/hugin/src/hugin/AutoCtrlPointCreator.cpp,v retrieving revision 1.36 retrieving revision 1.37 diff -u -d -r1.36 -r1.37 --- AutoCtrlPointCreator.cpp 27 Apr 2005 18:34:11 -0000 1.36 +++ AutoCtrlPointCreator.cpp 15 May 2005 14:03:07 -0000 1.37 @@ -40,6 +40,7 @@ #ifdef __WXMAC__ #include <CFBundle.h> +#include "wx/mac/private.h" #include <wx/utils.h> #endif @@ -175,18 +176,18 @@ } else { - CFIndex bufLen = 1024; - unsigned char buffer[(int) bufLen]; - if(!CFURLGetFileSystemRepresentation(XRCurl, TRUE, buffer, bufLen)) + CFStringRef pathInCFString = CFURLCopyFileSystemPath(XRCurl, kCFURLPOSIXPathStyle); + if(!pathInCFString) { - CFRelease(XRCurl); - DEBUG_INFO("Mac: Failed to get file system representation"); + CFRelease( XRCurl ); + DEBUG_INFO("Mac: Failed to get URL in CFString"); } else { - buffer[((int) bufLen) - 1] = '\0'; - CFRelease(XRCurl); - autopanoExe = wxString::FromAscii( (char *) buffer); + CFRelease( XRCurl ); + wxString pathInWXString = wxMacCFStringHolder(pathInCFString).AsString(wxLocale::GetSystemEncoding()); + + autopanoExe = pathInWXString; DEBUG_INFO("Mac: using bundled autopano-sift frontend script"); wxConfigBase::Get()->Write(wxT("/AutopanoSift/AutopanoExe"), wxT(HUGIN_APSIFT_EXE)); Index: huginApp.cpp =================================================================== RCS file: /cvsroot/hugin/hugin/src/hugin/huginApp.cpp,v retrieving revision 1.80 retrieving revision 1.81 diff -u -d -r1.80 -r1.81 --- huginApp.cpp 10 May 2005 11:01:23 -0000 1.80 +++ huginApp.cpp 15 May 2005 14:03:07 -0000 1.81 @@ -29,6 +29,7 @@ //Mac bundle code by Ippei #ifdef __WXMAC__ #include <CFBundle.h> +#include "wx/mac/private.h" #endif #include "panoinc_WX.h" @@ -124,6 +125,45 @@ if (config->HasEntry(wxT("locale_path"))){ locale.AddCatalogLookupPathPrefix( config->Read(wxT("locale_path")).c_str() ); } + + /* start: Mac code by Ippei*/ +#ifdef __WXMAC__ + + CFBundleRef mainbundle = CFBundleGetMainBundle(); + + + if(!mainbundle) + { + DEBUG_INFO("Mac: Not bundled"); + } + else + { + CFURLRef XRCurl = CFBundleCopyResourceURL(mainbundle, CFSTR("locale"), NULL, NULL); + if(!XRCurl) + { + DEBUG_INFO("Mac: Cannot locate xrc in the bundle."); + } + else + { + CFStringRef pathInCFString = CFURLCopyFileSystemPath(XRCurl, kCFURLPOSIXPathStyle); + if(!pathInCFString) + { + CFRelease( XRCurl ); + DEBUG_INFO("Mac: Failed to get URL in CFString"); + } + else + { + CFRelease( XRCurl ); + wxString pathInWXString = wxMacCFStringHolder(pathInCFString).AsString(wxLocale::GetSystemEncoding()); + + locale.AddCatalogLookupPathPrefix(pathInWXString); + DEBUG_INFO("Mac: locale.AddCatalogLookupPathPrefix; using mac bundled locale directories"); + } + } + } + + /* end: Mac code by Ippei*/ +#endif // set the name of locale recource to look for locale.AddCatalog(wxT("hugin")); @@ -159,7 +199,8 @@ /* start: Mac code by Ippei*/ #ifdef __WXMAC__ - CFBundleRef mainbundle = CFBundleGetMainBundle(); +// CFBundleRef mainbundle = CFBundleGetMainBundle(); + if(!mainbundle) { DEBUG_INFO("Mac: Not bundled"); @@ -173,18 +214,18 @@ } else { - CFIndex bufLen = 1024; - unsigned char buffer[(int) bufLen]; - if(!CFURLGetFileSystemRepresentation(XRCurl, TRUE, buffer, bufLen)) + CFStringRef pathInCFString = CFURLCopyFileSystemPath(XRCurl, kCFURLPOSIXPathStyle); + if(!pathInCFString) { - CFRelease(XRCurl); - DEBUG_INFO("Mac: Failed to get file system representation"); + CFRelease( XRCurl ); + DEBUG_INFO("Mac: Failed to get URL in CFString"); } else { - buffer[((int) bufLen) - 1] = '\0'; - CFRelease(XRCurl); - xrcPrefix = wxString::FromAscii( (char *) buffer) + wxT("/"); + CFRelease( XRCurl ); + wxString pathInWXString = wxMacCFStringHolder(pathInCFString).AsString(wxLocale::GetSystemEncoding()); + + xrcPrefix = pathInWXString + wxT("/"); DEBUG_INFO("Mac: overriding xrc prefix; using mac bundled xrc files"); } Index: MainFrame.cpp =================================================================== RCS file: /cvsroot/hugin/hugin/src/hugin/MainFrame.cpp,v retrieving revision 1.141 retrieving revision 1.142 diff -u -d -r1.141 -r1.142 --- MainFrame.cpp 10 May 2005 11:01:23 -0000 1.141 +++ MainFrame.cpp 15 May 2005 14:03:07 -0000 1.142 @@ -32,6 +32,7 @@ //Mac bundle code by Ippei #ifdef __WXMAC__ #include <CFBundle.h> +#include "wx/mac/private.h" #endif #include "vigra_ext/Correlation.h" @@ -206,18 +207,18 @@ } else { - CFIndex bufLen = 1024; - unsigned char buffer[(int) bufLen]; - if(!CFURLGetFileSystemRepresentation(XRCurl, TRUE, buffer, bufLen)) + CFStringRef pathInCFString = CFURLCopyFileSystemPath(XRCurl, kCFURLPOSIXPathStyle); + if(!pathInCFString) { - CFRelease(XRCurl); - DEBUG_INFO("Mac: Failed to get file system representation"); + CFRelease( XRCurl ); + DEBUG_INFO("Mac: Failed to get URL in CFString"); } else { - buffer[((int) bufLen) - 1] = '\0'; - CFRelease(XRCurl); - m_xrcPrefix = wxString::FromAscii( (char *) buffer) + wxT("/"); + CFRelease( XRCurl ); + wxString pathInWXString = wxMacCFStringHolder(pathInCFString).AsString(wxLocale::GetSystemEncoding()); + + m_xrcPrefix = pathInWXString + wxT("/"); DEBUG_INFO("Mac: overriding xrc prefix; using mac bundled xrc files"); } } |