mirror of https://github.com/encounter/SDL.git
SDL_SetWindowTitle() should never set a NULL pointer for the title string.
Various backends reacted differently (or not at all) in the presence of a NULL pointer. This simplifies things. Fixes Bugzilla #2902.
This commit is contained in:
parent
1339ce71f6
commit
6e53bc9b10
|
@ -1502,11 +1502,8 @@ SDL_SetWindowTitle(SDL_Window * window, const char *title)
|
|||
return;
|
||||
}
|
||||
SDL_free(window->title);
|
||||
if (title && *title) {
|
||||
window->title = SDL_strdup(title);
|
||||
} else {
|
||||
window->title = NULL;
|
||||
}
|
||||
|
||||
window->title = SDL_strdup(title ? title : "");
|
||||
|
||||
if (_this->SetWindowTitle) {
|
||||
_this->SetWindowTitle(_this, window);
|
||||
|
|
|
@ -1189,16 +1189,9 @@ Cocoa_SetWindowTitle(_THIS, SDL_Window * window)
|
|||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||
NSString *string;
|
||||
|
||||
if(window->title) {
|
||||
string = [[NSString alloc] initWithUTF8String:window->title];
|
||||
} else {
|
||||
string = [[NSString alloc] init];
|
||||
}
|
||||
NSString *string = [[NSString alloc] initWithUTF8String:window->title];
|
||||
[nswindow setTitle:string];
|
||||
[string release];
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
|
|
|
@ -161,7 +161,7 @@ DirectFB_WM_RedrawLayout(_THIS, SDL_Window * window)
|
|||
y, w - 2 * d);
|
||||
|
||||
/* Caption */
|
||||
if (window->title) {
|
||||
if (*window->title) {
|
||||
s->SetColor(s, COLOR_EXPAND(t->font_color));
|
||||
DrawCraption(_this, s, (x - w) / 2, t->top_size + d, window->title);
|
||||
}
|
||||
|
|
|
@ -371,14 +371,8 @@ void
|
|||
WIN_SetWindowTitle(_THIS, SDL_Window * window)
|
||||
{
|
||||
HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
|
||||
LPTSTR title;
|
||||
|
||||
if (window->title) {
|
||||
title = WIN_UTF8ToString(window->title);
|
||||
} else {
|
||||
title = NULL;
|
||||
}
|
||||
SetWindowText(hwnd, title ? title : TEXT(""));
|
||||
LPTSTR title = WIN_UTF8ToString(window->title);
|
||||
SetWindowText(hwnd, title);
|
||||
SDL_free(title);
|
||||
}
|
||||
|
||||
|
|
|
@ -658,39 +658,39 @@ X11_SetWindowTitle(_THIS, SDL_Window * window)
|
|||
Display *display = data->videodata->display;
|
||||
XTextProperty titleprop, iconprop;
|
||||
Status status;
|
||||
const char *title = window->title;
|
||||
const char *title = window->title ? window->title : "";
|
||||
const char *icon = NULL;
|
||||
char *title_locale = NULL;
|
||||
|
||||
#ifdef X_HAVE_UTF8_STRING
|
||||
Atom _NET_WM_NAME = data->videodata->_NET_WM_NAME;
|
||||
Atom _NET_WM_ICON_NAME = data->videodata->_NET_WM_ICON_NAME;
|
||||
#endif
|
||||
|
||||
if (title != NULL) {
|
||||
char *title_locale = SDL_iconv_utf8_locale(title);
|
||||
if (!title_locale) {
|
||||
SDL_OutOfMemory();
|
||||
return;
|
||||
}
|
||||
status = X11_XStringListToTextProperty(&title_locale, 1, &titleprop);
|
||||
SDL_free(title_locale);
|
||||
if (status) {
|
||||
X11_XSetTextProperty(display, data->xwindow, &titleprop, XA_WM_NAME);
|
||||
title_locale = SDL_iconv_utf8_locale(title);
|
||||
if (!title_locale) {
|
||||
SDL_OutOfMemory();
|
||||
return;
|
||||
}
|
||||
|
||||
status = X11_XStringListToTextProperty(&title_locale, 1, &titleprop);
|
||||
SDL_free(title_locale);
|
||||
if (status) {
|
||||
X11_XSetTextProperty(display, data->xwindow, &titleprop, XA_WM_NAME);
|
||||
X11_XFree(titleprop.value);
|
||||
}
|
||||
#ifdef X_HAVE_UTF8_STRING
|
||||
if (SDL_X11_HAVE_UTF8) {
|
||||
status = X11_Xutf8TextListToTextProperty(display, (char **) &title, 1,
|
||||
XUTF8StringStyle, &titleprop);
|
||||
if (status == Success) {
|
||||
X11_XSetTextProperty(display, data->xwindow, &titleprop,
|
||||
_NET_WM_NAME);
|
||||
X11_XFree(titleprop.value);
|
||||
}
|
||||
#ifdef X_HAVE_UTF8_STRING
|
||||
if (SDL_X11_HAVE_UTF8) {
|
||||
status =
|
||||
X11_Xutf8TextListToTextProperty(display, (char **) &title, 1,
|
||||
XUTF8StringStyle, &titleprop);
|
||||
if (status == Success) {
|
||||
X11_XSetTextProperty(display, data->xwindow, &titleprop,
|
||||
_NET_WM_NAME);
|
||||
X11_XFree(titleprop.value);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
if (icon != NULL) {
|
||||
char *icon_locale = SDL_iconv_utf8_locale(icon);
|
||||
if (!icon_locale) {
|
||||
|
|
Loading…
Reference in New Issue