mirror of
https://github.com/HeidiSQL/HeidiSQL.git
synced 2025-08-06 18:24:26 +08:00
Fix access violation when using ASCIIencoding, by turning it from a SingleTon into a new instance each time we call GetEncodingByName. Probably introduces a memory leak. The encoding object is freed when using in a TStringStream context which is freed after usage. See exportgrid unit.
This commit is contained in:
@ -327,7 +327,6 @@ type
|
||||
var
|
||||
AppSettings: TAppSettings;
|
||||
MutexHandle: THandle = 0;
|
||||
ASCIIEncoding: TEncoding;
|
||||
|
||||
|
||||
implementation
|
||||
@ -2449,7 +2448,7 @@ begin
|
||||
Result := '';
|
||||
if Encoding = TEncoding.Default then
|
||||
Result := 'Windows-'+IntToStr(GetACP)
|
||||
else if Encoding = ASCIIEncoding then
|
||||
else if Encoding.CodePage = 437 then
|
||||
Result := 'ascii'
|
||||
else if Encoding = TEncoding.Unicode then
|
||||
Result := 'utf-16le'
|
||||
|
@ -1580,7 +1580,6 @@ begin
|
||||
FTreeRefreshInProgress := False;
|
||||
|
||||
FileEncodings := Explode(',', 'Auto detect (may fail),ANSI,ASCII,Unicode,Unicode Big Endian,UTF-8,UTF-7');
|
||||
ASCIIEncoding := TEncoding.GetEncoding(437);
|
||||
end;
|
||||
|
||||
|
||||
@ -10118,11 +10117,13 @@ end;
|
||||
|
||||
|
||||
function TMainForm.GetEncodingByName(Name: String): TEncoding;
|
||||
var
|
||||
Enc: TEncoding;
|
||||
begin
|
||||
Result := nil;
|
||||
case FileEncodings.IndexOf(Name) of
|
||||
1: Result := TEncoding.Default;
|
||||
2: Result := ASCIIEncoding;
|
||||
2: Result := TEncoding.GetEncoding(437);
|
||||
3: Result := TEncoding.Unicode;
|
||||
4: Result := TEncoding.BigEndianUnicode;
|
||||
5: Result := TEncoding.UTF8;
|
||||
@ -10136,7 +10137,7 @@ var
|
||||
idx: Integer;
|
||||
begin
|
||||
if Encoding = TEncoding.Default then idx := 1
|
||||
else if Encoding = ASCIIEncoding then idx := 2
|
||||
else if Encoding.CodePage = 437 then idx := 2
|
||||
else if Encoding = TEncoding.Unicode then idx := 3
|
||||
else if Encoding = TEncoding.BigEndianUnicode then idx := 4
|
||||
else if Encoding = TEncoding.UTF8 then idx := 5
|
||||
@ -10201,7 +10202,7 @@ begin
|
||||
54936: Result := 'gb18030';
|
||||
65001: Result := 'utf8';
|
||||
end;
|
||||
end else if Encoding = ASCIIEncoding then
|
||||
end else if Encoding.CodePage = 437 then
|
||||
Result := 'ascii'
|
||||
else if Encoding = TEncoding.Unicode then
|
||||
Result := 'utf16le'
|
||||
|
Reference in New Issue
Block a user