IDE: fixed crash when freeing package after package editors

git-svn-id: trunk@34681 -
This commit is contained in:
mattias 2012-01-09 14:58:38 +00:00
parent 0bba1c10de
commit ce9d9d44a2
9 changed files with 35 additions and 6 deletions

View File

@ -368,8 +368,10 @@ begin
UncompressedMS.Position:=0;
// reduce the risk of file corruption due to crashes while saving:
// save to a temporary file and then rename
TempFilename:=FileProcs.GetTempFilename(Filename,'unitdictionary');
TempFilename:=FileProcs.GetTempFilename(Filename,'writing_tmp_');
UncompressedMS.SaveToFile(TempFilename);
if not DeleteFileUTF8(Filename) then
raise Exception.Create(Format(crsUnableToDelete, [Filename]));
if not RenameFileUTF8(TempFilename,Filename) then
raise Exception.Create(Format(crsUnableToRenameTo, [TempFilename,
Filename]));

View File

@ -175,6 +175,7 @@ resourcestring
crsAndMoreIdentifiers = '... and %s more identifiers';
crsCodyIdentifierDictionary = 'Identifier Dictionary';
crsUnableToRenameTo = 'unable to rename "%s" to "%s"';
crsUnableToDelete = 'Unable to delete "%s"';
crsPackagesUnitsIdentifiersFile = 'Packages: %s, Units: %s, Identifiers: %s%'
+'sDatabase: %s';
crsNoneSelected = 'none selected';

View File

@ -529,6 +529,10 @@ msgstr "Total"
msgid "Type"
msgstr "Typ"
#: codystrconsts.crsunabletodelete
msgid "Unable to delete \"%s\""
msgstr ""
#: codystrconsts.crsunabletoreadfile
msgid "Unable to read file \"%s\"."
msgstr "Kann Datei \"%s\" nicht lesen."

View File

@ -534,6 +534,10 @@ msgstr "Totale"
msgid "Type"
msgstr ""
#: codystrconsts.crsunabletodelete
msgid "Unable to delete \"%s\""
msgstr ""
#: codystrconsts.crsunabletoreadfile
msgid "Unable to read file \"%s\"."
msgstr ""

View File

@ -521,6 +521,10 @@ msgstr ""
msgid "Type"
msgstr ""
#: codystrconsts.crsunabletodelete
msgid "Unable to delete \"%s\""
msgstr ""
#: codystrconsts.crsunabletoreadfile
msgid "Unable to read file \"%s\"."
msgstr ""

View File

@ -542,6 +542,10 @@ msgstr "Total"
msgid "Type"
msgstr "Tipo"
#: codystrconsts.crsunabletodelete
msgid "Unable to delete \"%s\""
msgstr ""
#: codystrconsts.crsunabletoreadfile
msgid "Unable to read file \"%s\"."
msgstr "Incapaz de ler o arquivo \"%s\"."

View File

@ -543,6 +543,10 @@ msgstr "Всего"
msgid "Type"
msgstr "Тип"
#: codystrconsts.crsunabletodelete
msgid "Unable to delete \"%s\""
msgstr ""
#: codystrconsts.crsunabletoreadfile
msgid "Unable to read file \"%s\"."
msgstr "Невозможно прочитать файл \"%s\"."

View File

@ -547,6 +547,10 @@ msgstr "Загалом"
msgid "Type"
msgstr "Тип"
#: codystrconsts.crsunabletodelete
msgid "Unable to delete \"%s\""
msgstr ""
#: codystrconsts.crsunabletoreadfile
msgid "Unable to read file \"%s\"."
msgstr ""

View File

@ -294,7 +294,7 @@ type
TPackageEditors = class
private
FItems: TList; // list of TPackageEditorForm
FItems: TFPList; // list of TPackageEditorForm
FOnAddToProject: TOnAddPkgToProject;
FOnAfterWritePackage: TIDEOptionsWriteEvent;
FOnBeforeReadPackage: TNotifyEvent;
@ -2293,13 +2293,13 @@ end;
constructor TPackageEditors.Create;
begin
FItems:=TList.Create;
FItems:=TFPList.Create;
end;
destructor TPackageEditors.Destroy;
begin
Clear;
FItems.Free;
FreeAndNil(FItems);
inherited Destroy;
end;
@ -2315,7 +2315,8 @@ end;
procedure TPackageEditors.Remove(Editor: TPackageEditorForm);
begin
FItems.Remove(Editor);
if FItems<>nil then
FItems.Remove(Editor);
end;
function TPackageEditors.IndexOfPackage(Pkg: TLazPackage): integer;
@ -2378,7 +2379,8 @@ end;
procedure TPackageEditors.DoFreeEditor(Pkg: TLazPackage);
begin
FItems.Remove(Pkg.Editor);
if FItems<>nil then
FItems.Remove(Pkg.Editor);
if Assigned(OnFreeEditor) then OnFreeEditor(Pkg);
end;