From: DeaDDooMER Date: Wed, 13 Jul 2022 14:20:06 +0000 (+0300) Subject: sdl1/2: fix invalid window title X-Git-Url: http://deadsoftware.ru/gitweb?p=d2df-sdl.git;a=commitdiff_plain;h=a280ce1ab3f2d28a227e7cf492a12c749e4d5290 sdl1/2: fix invalid window title --- diff --git a/src/game/sdl/g_system.pas b/src/game/sdl/g_system.pas index 1f4061a..0df28dc 100644 --- a/src/game/sdl/g_system.pas +++ b/src/game/sdl/g_system.pas @@ -124,17 +124,17 @@ implementation g_Game_ClearLoading; end; - function GetTitle (): PChar; + function GetTitle (): AnsiString; var info: AnsiString; begin info := g_GetBuildHash(false); if info = 'custom build' then info := info + ' by ' + g_GetBuilderName() + ' ' + GAME_BUILDDATE + ' ' + GAME_BUILDTIME; - result := PChar(Format(GameTitle, [info])) + result := Format(GameTitle, [info]); end; function InitWindow (w, h, bpp: Integer; fullScreen: Boolean): Boolean; - var flags: Uint32; + var flags: Uint32; title: AnsiString; begin e_LogWritefln('InitWindow %s %s %s %s', [w, h, bpp, fullScreen]); result := false; @@ -158,7 +158,8 @@ implementation e_LogWriteln('GL: unable to load OpenGL functions', TMsgType.Fatal); exit; end; - SDL_WM_SetCaption(GetTitle(), nil); + title := GetTitle(); + SDL_WM_SetCaption(PChar(title), nil); gFullScreen := fullscreen; gRC_FullScreen := fullscreen; UpdateSize(w, h); @@ -184,7 +185,7 @@ implementation function sys_GetDisplayModes (bpp: Integer): SSArray; var m: PPSDL_Rect; f: TSDL_PixelFormat; i, count: Integer; begin - SetLength(result, 0); + result := nil; FillChar(f, sizeof(f), 0); f.palette := nil; f.BitsPerPixel := bpp; diff --git a/src/game/sdl2/g_system.pas b/src/game/sdl2/g_system.pas index eec0323..9cd1ee1 100644 --- a/src/game/sdl2/g_system.pas +++ b/src/game/sdl2/g_system.pas @@ -134,17 +134,17 @@ implementation {$ENDIF} end; - function GetTitle (): PChar; + function GetTitle (): AnsiString; var info: AnsiString; begin info := g_GetBuildHash(false); if info = 'custom build' then info := info + ' by ' + g_GetBuilderName() + ' ' + GAME_BUILDDATE + ' ' + GAME_BUILDTIME; - result := PChar(Format(GameTitle, [info])) + result := Format(GameTitle, [info]); end; function InitWindow (w, h, bpp: Integer; fullScreen, maximized: Boolean): Boolean; - var flags: UInt32; x, y: cint; + var flags: UInt32; x, y: cint; title: AnsiString; begin // note: on window close make: if assigned(oglDeinitCB) then oglDeinitCB; e_LogWritefln('InitWindow %s %s %s %s', [w, h, bpp, fullScreen]); @@ -178,7 +178,8 @@ implementation x := wx; y := wy end; - window := SDL_CreateWindow(GetTitle(), x, y, w, h, flags); + title := GetTitle(); + window := SDL_CreateWindow(PChar(title), x, y, w, h, flags); if window <> nil then begin context := SDL_GL_CreateContext(window);