mirror of
https://github.com/kovidgoyal/kitty.git
synced 2026-10-10 05:45:35 +00:00
macOS: Fix an abort due to an assertion when a program tries to set an invalid window title
Fixes #7271
This commit is contained in:
parent
e5a7554c30
commit
8335a5212e
4 changed files with 9 additions and 2 deletions
|
|
@ -72,6 +72,8 @@ Detailed list of changes
|
|||
|
||||
- Splits layout: Fix :ac:`move_window_forward` not working (:iss:`7264`)
|
||||
|
||||
- macOS: Fix an abort due to an assertion when a program tries to set an invalid window title (:iss:`7271`)
|
||||
|
||||
0.33.1 [2024-03-21]
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
|
|
|
|||
|
|
@ -1963,9 +1963,11 @@ void _glfwPlatformDestroyWindow(_GLFWwindow* window)
|
|||
window->ns.object = nil;
|
||||
}
|
||||
|
||||
void _glfwPlatformSetWindowTitle(_GLFWwindow* window UNUSED, const char* title)
|
||||
void _glfwPlatformSetWindowTitle(_GLFWwindow* window, const char* title)
|
||||
{
|
||||
if (!title) return;
|
||||
NSString* string = @(title);
|
||||
if (!string) return; // the runtime failed to convert title to an NSString
|
||||
[window->ns.object setTitle:string];
|
||||
// HACK: Set the miniwindow title explicitly as setTitle: doesn't update it
|
||||
// if the window lacks NSWindowStyleMaskTitled
|
||||
|
|
|
|||
|
|
@ -748,12 +748,14 @@ cocoa_create_global_menu(void) {
|
|||
|
||||
void
|
||||
cocoa_update_menu_bar_title(PyObject *pytitle) {
|
||||
if (!pytitle) return;
|
||||
NSString *title = nil;
|
||||
if (OPT(macos_menubar_title_max_length) > 0 && PyUnicode_GetLength(pytitle) > OPT(macos_menubar_title_max_length)) {
|
||||
static char fmt[64];
|
||||
snprintf(fmt, sizeof(fmt), "%%%ld.%ldU%%s", OPT(macos_menubar_title_max_length), OPT(macos_menubar_title_max_length));
|
||||
RAII_PyObject(st, PyUnicode_FromFormat(fmt, pytitle, "…"));
|
||||
if (st) title = @(PyUnicode_AsUTF8(st));
|
||||
else PyErr_Print();
|
||||
} else {
|
||||
title = @(PyUnicode_AsUTF8(pytitle));
|
||||
}
|
||||
|
|
|
|||
|
|
@ -98,7 +98,8 @@ update_menu_bar_title(PyObject *title UNUSED) {
|
|||
static char buf[2048];
|
||||
strip_csi_(PyUnicode_AsUTF8(title), buf, arraysz(buf));
|
||||
RAII_PyObject(stitle, PyUnicode_FromString(buf));
|
||||
cocoa_update_menu_bar_title(stitle);
|
||||
if (stitle) cocoa_update_menu_bar_title(stitle);
|
||||
else PyErr_Print();
|
||||
#endif
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue