fixing strings management

This commit is contained in:
Kbz-8
2025-10-16 10:36:31 +02:00
parent 73d31c196e
commit 0d0d2d4451

View File

@@ -187,9 +187,11 @@ class Context:
resizable: bool = True, resizable: bool = True,
fullscreen: bool = False, fullscreen: bool = False,
) -> "Window": ) -> "Window":
ffi_title = ffi.new("char[]", title.encode('ascii', 'replace'))
info = ffi.new("mlx_window_create_info*") info = ffi.new("mlx_window_create_info*")
info.render_target = ffi.NULL info.render_target = ffi.NULL
info.title = ffi.from_buffer(title.encode("utf-8")) info.title = ffi_title
info.width = int(width) info.width = int(width)
info.height = int(height) info.height = int(height)
info.is_fullscreen = bool(fullscreen) info.is_fullscreen = bool(fullscreen)
@@ -230,7 +232,8 @@ class Window:
self._win = win self._win = win
def set_title(self, title: str) -> None: def set_title(self, title: str) -> None:
lib.mlx_set_window_title(self._ctx._ctx, self._win, ffi.from_buffer(title.encode("utf-8"))) ffi_title = ffi.new("char[]", title.encode('ascii', 'replace'))
lib.mlx_set_window_title(self._ctx._ctx, self._win, ffi_title)
def clear(self, rgba: int) -> None: def clear(self, rgba: int) -> None:
lib.mlx_clear_window(self._ctx._ctx, self._win, _rgbaToColor(rgba)) lib.mlx_clear_window(self._ctx._ctx, self._win, _rgbaToColor(rgba))