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; UncompressedMS.Position:=0;
// reduce the risk of file corruption due to crashes while saving: // reduce the risk of file corruption due to crashes while saving:
// save to a temporary file and then rename // save to a temporary file and then rename
TempFilename:=FileProcs.GetTempFilename(Filename,'unitdictionary'); TempFilename:=FileProcs.GetTempFilename(Filename,'writing_tmp_');
UncompressedMS.SaveToFile(TempFilename); UncompressedMS.SaveToFile(TempFilename);
if not DeleteFileUTF8(Filename) then
raise Exception.Create(Format(crsUnableToDelete, [Filename]));
if not RenameFileUTF8(TempFilename,Filename) then if not RenameFileUTF8(TempFilename,Filename) then
raise Exception.Create(Format(crsUnableToRenameTo, [TempFilename, raise Exception.Create(Format(crsUnableToRenameTo, [TempFilename,
Filename])); Filename]));

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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

View File

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