r15414 by craig - #9316: Fix for bundle paths with unicode chars

scribus-commit scribus-commit at lists.scribus.net
Fri Aug 13 00:49:35 CEST 2010


Author: craig
Date: Thu Aug 12 22:49:34 2010
New Revision: 15414

URL: http://scribus.info/websvn/listing.php?repname=Scribus&sc=1&rev=15414
Log:
#9316: Fix for bundle paths with unicode chars

Modified:
    branches/Version135/Scribus/scribus/scpaths.cpp

Modified: branches/Version135/Scribus/scribus/scpaths.cpp
URL: http://scribus.info/websvn/diff.php?repname=Scribus&rev=15414&path=/branches/Version135/Scribus/scribus/scpaths.cpp
==============================================================================
--- branches/Version135/Scribus/scribus/scpaths.cpp (original)
+++ branches/Version135/Scribus/scribus/scpaths.cpp Thu Aug 12 22:49:34 2010
@@ -146,38 +146,53 @@
 QString ScPaths::bundleDir(void) const
 {
 	// On MacOS/X, override the compile-time settings with a location
-// obtained from the system.
+	// obtained from the system.
 #ifdef Q_WS_MAC
 	// Set up the various app paths to look inside the app bundle
 	CFURLRef pluginRef = CFBundleCopyBundleURL(CFBundleGetMainBundle());
-	CFStringRef macPath = CFURLCopyFileSystemPath(pluginRef,
-										   kCFURLPOSIXPathStyle);
-	const char *pathPtr = CFStringGetCStringPtr(macPath,
-										   CFStringGetSystemEncoding());
-
-	// make sure we get the Scribus.app directory, not some subdir
-
-	// strip trailing '/':
-	char *p = const_cast<char*>(pathPtr + strlen(pathPtr) - 1);
-	while (*p == '/')
-		--p;
-	++p;
-	*p = '\0';
-	if (strcmp("/bin", p-4) == 0) {
-		p -= 4;
+	CFStringRef macPath = CFURLCopyFileSystemPath(pluginRef, kCFURLPOSIXPathStyle);
+	const char *pathPtr = CFStringGetCStringPtr(macPath, CFStringGetSystemEncoding());
+	if (pathPtr!=NULL && strlen(pathPtr)>0)
+	{
+		// make sure we get the Scribus.app directory, not some subdir
+		// strip trailing '/':
+		qDebug("Path = %s", pathPtr);
+		char *p = const_cast<char*>(pathPtr + strlen(pathPtr) - 1);
+		while (*p == '/')
+			--p;
+		++p;
 		*p = '\0';
-	}
-	if (strcmp("/MacOS", p-6) == 0) {
-		p -= 6;
-		*p = '\0';
-	}
-	if (strcmp("/Contents", p-9) == 0) {
-		p -= 9;
-		*p = '\0';
-	}
-	CFRelease(pluginRef);
-	CFRelease(macPath);
-	return QString("%1").arg(pathPtr);
+		if (strcmp("/bin", p-4) == 0) {
+			p -= 4;
+			*p = '\0';
+		}
+		if (strcmp("/MacOS", p-6) == 0) {
+			p -= 6;
+			*p = '\0';
+		}
+		if (strcmp("/Contents", p-9) == 0) {
+			p -= 9;
+			*p = '\0';
+		}
+		CFRelease(pluginRef);
+		CFRelease(macPath);
+		return QString("%1").arg(pathPtr);
+	}
+	else
+	{
+		char buf[2048];
+		CFStringGetCString (macPath, buf, 2048, kCFStringEncodingUTF8);
+		QString q_pathPtr=QString::fromUtf8(buf);
+		if (q_pathPtr.endsWith("/bin"))
+			q_pathPtr.chop(4);
+		if (q_pathPtr.endsWith("/MacOS"))
+			q_pathPtr.chop(6);
+		if (q_pathPtr.endsWith("/Contents"))
+			q_pathPtr.chop(9);
+		CFRelease(pluginRef);
+		CFRelease(macPath);
+		return q_pathPtr;
+	}
 #endif
 	return QString::null;
 }




More information about the scribus-commit mailing list