OSX/Cocoa: Fix [#24068] for correct handling of .blend file names with accented nordi...
authorDamien Plisson <damien.plisson@yahoo.fr>
Sat, 2 Oct 2010 09:17:32 +0000 (09:17 +0000)
committerDamien Plisson <damien.plisson@yahoo.fr>
Sat, 2 Oct 2010 09:17:32 +0000 (09:17 +0000)
intern/ghost/intern/GHOST_WindowCocoa.mm

index aed9bd07cdc01104e134fe5b14d3d3e36bcea43b..c43a9b57721cc6d6d4e0d54bf809ab194362d0e5 100644 (file)
@@ -493,10 +493,10 @@ void GHOST_WindowCocoa::setTitle(const STR_String& title)
     GHOST_ASSERT(getValid(), "GHOST_WindowCocoa::setTitle(): window invalid")
        NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
 
-       NSString *windowTitle = [[NSString alloc] initWithUTF8String:title];
+       NSString *windowTitle = [[NSString alloc] initWithCString:title encoding:NSISOLatin1StringEncoding];
        
        //Set associated file if applicable
-       if ([windowTitle hasPrefix:@"Blender"])
+       if (windowTitle && [windowTitle hasPrefix:@"Blender"])
        {
                NSRange fileStrRange;
                NSString *associatedFileName;
@@ -509,13 +509,16 @@ void GHOST_WindowCocoa::setTitle(const STR_String& title)
                {
                        fileStrRange.length = len;
                        associatedFileName = [windowTitle substringWithRange:fileStrRange];
+                       [m_window setTitle:[associatedFileName lastPathComponent]];
+
+                       //Blender used file open/save functions converte file names into legal URL ones
+                       associatedFileName = [associatedFileName stringByAddingPercentEscapesUsingEncoding:NSISOLatin1StringEncoding];
                        @try {
                                [m_window setRepresentedFilename:associatedFileName];
                        }
                        @catch (NSException * e) {
                                printf("\nInvalid file path given in window title");
                        }
-                       [m_window setTitle:[associatedFileName lastPathComponent]];
                }
                else {
                        [m_window setTitle:windowTitle];