Compare commits

...

3 Commits

Author SHA1 Message Date
Jan Middelburg 23b69058ab
Part of memory leak fix 2021-12-03 13:48:13 +01:00
Jan Middelburg 2d17084724
Fixed warning on Destroy 2021-12-03 13:24:23 +01:00
Jan Middelburg c0ca278638
Memory issue when using SHGetSpecialFolderLocation (deprecated) 2021-12-03 13:23:05 +01:00
3 changed files with 54 additions and 23 deletions

View File

@ -418,33 +418,43 @@ procedure TX2App.GetPath();
(APath);
end;
var
ifMalloc: IMalloc;
pIDL: PItemIDList;
cPath: array[0..MAX_PATH] of Char;
{$IFNDEF DXE2PLUS}
procedure GetPaths;
var
ifMalloc: IMalloc;
pIDL: PItemIDList;
cPath: array[0..MAX_PATH] of Char;
begin
SHGetMalloc(ifMalloc);
try
FillChar(cPath, SizeOf(cPath), #0);
SHGetSpecialFolderLocation(0, CSIDL_APPDATA, pIDL);
SHGetPathFromIDList(pIDL, @cPath);
FUserPath := FixPath(cPath);
cPath := '';
FillChar(cPath, SizeOf(cPath), #0);
SHGetSpecialFolderLocation(0, CSIDL_COMMON_APPDATA, pIDL);
SHGetPathFromIDList(pIDL, @cPath);
FProgramDataPath := FixPath(cPath);
finally
ifMalloc := nil;
end;
end;
{$ENDIF}
begin
FFileName := GetModule(SysInit.HInstance);
FPath := FixPath(ExtractFilePath(FFileName));
FMainPath := FixPath(ExtractFilePath(GetModule(0)));
SHGetMalloc(ifMalloc);
try
FillChar(cPath, SizeOf(cPath), #0);
SHGetSpecialFolderLocation(0, CSIDL_APPDATA, pIDL);
SHGetPathFromIDList(pIDL, @cPath);
FUserPath := FixPath(cPath);
FillChar(cPath, SizeOf(cPath), #0);
SHGetSpecialFolderLocation(0, CSIDL_COMMON_APPDATA, pIDL);
SHGetPathFromIDList(pIDL, @cPath);
FProgramDataPath := FixPath(cPath);
finally
ifMalloc := nil;
end;
{$IFDEF DXE2PLUS}
FUserPath := FixPath(System.IOUtils.TPath.GetHomePath);
FProgramDataPath := FixPath(System.IOUtils.TPath.GetPublicPath);
{$ELSE}
GetPaths;
{$ENDIF}
end;

View File

@ -17,6 +17,26 @@
{$UNDEF D2}
{$UNDEF D1}
{$IFDEF VER320}
{$DEFINE DXE2}
{$DEFINE DXE2PLUS}
{$DEFINE DXEPLUS}
{$DEFINE D2010PLUS}
{$DEFINE D2009PLUS}
{$DEFINE D2007PLUS}
{$DEFINE D2006PLUS}
{$DEFINE D2005PLUS}
{$DEFINE D8PLUS}
{$DEFINE D7PLUS}
{$DEFINE D6PLUS}
{$DEFINE D5PLUS}
{$DEFINE D4PLUS}
{$DEFINE D3PLUS}
{$DEFINE D2PLUS}
{$DEFINE D1PLUS}
{$UNDEF DUNKNOWN}
{$ENDIF}
{$IFDEF VER230}
{$DEFINE DXE2}
{$DEFINE DXE2PLUS}

View File

@ -38,7 +38,6 @@ type
FServiceThread: TThread;
FAllowClose: Boolean;
protected
destructor Destroy; override;
procedure DoShow; override;
procedure UpdatePredefinedControlCodes; virtual;
@ -48,6 +47,8 @@ type
property ServiceThread: TThread read FServiceThread;
public
destructor Destroy; override;
property Context: IX2ServiceContext read FContext write FContext;
property Service: IX2Service read FService write FService;
end;