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;
|
return;
|
||||||
}
|
}
|
||||||
SDL_free(window->title);
|
SDL_free(window->title);
|
||||||
if (title && *title) {
|
|
||||||
window->title = SDL_strdup(title);
|
window->title = SDL_strdup(title ? title : "");
|
||||||
} else {
|
|
||||||
window->title = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_this->SetWindowTitle) {
|
if (_this->SetWindowTitle) {
|
||||||
_this->SetWindowTitle(_this, window);
|
_this->SetWindowTitle(_this, window);
|
||||||
|
|
|
@ -1189,16 +1189,9 @@ Cocoa_SetWindowTitle(_THIS, SDL_Window * window)
|
||||||
{
|
{
|
||||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||||
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
NSWindow *nswindow = ((SDL_WindowData *) window->driverdata)->nswindow;
|
||||||
NSString *string;
|
NSString *string = [[NSString alloc] initWithUTF8String:window->title];
|
||||||
|
|
||||||
if(window->title) {
|
|
||||||
string = [[NSString alloc] initWithUTF8String:window->title];
|
|
||||||
} else {
|
|
||||||
string = [[NSString alloc] init];
|
|
||||||
}
|
|
||||||
[nswindow setTitle:string];
|
[nswindow setTitle:string];
|
||||||
[string release];
|
[string release];
|
||||||
|
|
||||||
[pool release];
|
[pool release];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -161,7 +161,7 @@ DirectFB_WM_RedrawLayout(_THIS, SDL_Window * window)
|
||||||
y, w - 2 * d);
|
y, w - 2 * d);
|
||||||
|
|
||||||
/* Caption */
|
/* Caption */
|
||||||
if (window->title) {
|
if (*window->title) {
|
||||||
s->SetColor(s, COLOR_EXPAND(t->font_color));
|
s->SetColor(s, COLOR_EXPAND(t->font_color));
|
||||||
DrawCraption(_this, s, (x - w) / 2, t->top_size + d, window->title);
|
DrawCraption(_this, s, (x - w) / 2, t->top_size + d, window->title);
|
||||||
}
|
}
|
||||||
|
|
|
@ -371,14 +371,8 @@ void
|
||||||
WIN_SetWindowTitle(_THIS, SDL_Window * window)
|
WIN_SetWindowTitle(_THIS, SDL_Window * window)
|
||||||
{
|
{
|
||||||
HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
|
HWND hwnd = ((SDL_WindowData *) window->driverdata)->hwnd;
|
||||||
LPTSTR title;
|
LPTSTR title = WIN_UTF8ToString(window->title);
|
||||||
|
SetWindowText(hwnd, title);
|
||||||
if (window->title) {
|
|
||||||
title = WIN_UTF8ToString(window->title);
|
|
||||||
} else {
|
|
||||||
title = NULL;
|
|
||||||
}
|
|
||||||
SetWindowText(hwnd, title ? title : TEXT(""));
|
|
||||||
SDL_free(title);
|
SDL_free(title);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -658,39 +658,39 @@ X11_SetWindowTitle(_THIS, SDL_Window * window)
|
||||||
Display *display = data->videodata->display;
|
Display *display = data->videodata->display;
|
||||||
XTextProperty titleprop, iconprop;
|
XTextProperty titleprop, iconprop;
|
||||||
Status status;
|
Status status;
|
||||||
const char *title = window->title;
|
const char *title = window->title ? window->title : "";
|
||||||
const char *icon = NULL;
|
const char *icon = NULL;
|
||||||
|
char *title_locale = NULL;
|
||||||
|
|
||||||
#ifdef X_HAVE_UTF8_STRING
|
#ifdef X_HAVE_UTF8_STRING
|
||||||
Atom _NET_WM_NAME = data->videodata->_NET_WM_NAME;
|
Atom _NET_WM_NAME = data->videodata->_NET_WM_NAME;
|
||||||
Atom _NET_WM_ICON_NAME = data->videodata->_NET_WM_ICON_NAME;
|
Atom _NET_WM_ICON_NAME = data->videodata->_NET_WM_ICON_NAME;
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (title != NULL) {
|
title_locale = SDL_iconv_utf8_locale(title);
|
||||||
char *title_locale = SDL_iconv_utf8_locale(title);
|
if (!title_locale) {
|
||||||
if (!title_locale) {
|
SDL_OutOfMemory();
|
||||||
SDL_OutOfMemory();
|
return;
|
||||||
return;
|
}
|
||||||
}
|
|
||||||
status = X11_XStringListToTextProperty(&title_locale, 1, &titleprop);
|
status = X11_XStringListToTextProperty(&title_locale, 1, &titleprop);
|
||||||
SDL_free(title_locale);
|
SDL_free(title_locale);
|
||||||
if (status) {
|
if (status) {
|
||||||
X11_XSetTextProperty(display, data->xwindow, &titleprop, XA_WM_NAME);
|
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);
|
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) {
|
if (icon != NULL) {
|
||||||
char *icon_locale = SDL_iconv_utf8_locale(icon);
|
char *icon_locale = SDL_iconv_utf8_locale(icon);
|
||||||
if (!icon_locale) {
|
if (!icon_locale) {
|
||||||
|
|
Loading…
Reference in New Issue