[Commits] SDL: Better fix for bug 3048, don't crash if the window title is...

libsdl.org revision control commits-owner at libsdl.org
Sun Jul 5 15:45:51 PDT 2015


details:   https://hg.libsdl.org/SDL/rev/c142db5785ad
changeset: 9797:c142db5785ad
user:      Sam Lantinga <slouken at libsdl.org>
date:      Sun Jul 05 15:45:48 2015 -0700
description:
Better fix for bug 3048, don't crash if the window title is NULL

diffstat:

 src/video/cocoa/SDL_cocoawindow.m |  7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)

diffs (32 lines):

diff -r e0db4fedf80c -r c142db5785ad src/video/cocoa/SDL_cocoawindow.m
--- a/src/video/cocoa/SDL_cocoawindow.m	Sat Jul 04 21:04:49 2015 -0400
+++ b/src/video/cocoa/SDL_cocoawindow.m	Sun Jul 05 15:45:48 2015 -0700
@@ -1241,8 +1241,9 @@
 Cocoa_SetWindowTitle(_THIS, SDL_Window * window)
 { @autoreleasepool
 {
+    const char *title = window->title ? window->title : "";
     NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
-    NSString *string = [[NSString alloc] initWithUTF8String:window->title];
+    NSString *string = [[NSString alloc] initWithUTF8String:title];
     [nswindow setTitle:string];
     [string release];
 }}
@@ -1428,7 +1429,7 @@
 { @autoreleasepool
 {
     if (SetWindowStyle(window, GetWindowStyle(window))) {
-        if (bordered && window->title) {
+        if (bordered) {
             Cocoa_SetWindowTitle(_this, window);  /* this got blanked out. */
         }
     }
@@ -1499,7 +1500,7 @@
     s_moveHack = SDL_GetTicks();
 
     /* When the window style changes the title is cleared */
-    if (!fullscreen && window->title) {
+    if (!fullscreen) {
         Cocoa_SetWindowTitle(_this, window);
     }
 


More information about the commits mailing list