Changeset 34 for trunk/UAcronym.pas


Ignore:
Timestamp:
Jul 13, 2016, 3:24:45 PM (8 years ago)
Author:
chronos
Message:
  • Fixed: Error during removing acronyms in case that multiple acronyms with same name exists.
File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/UAcronym.pas

    r33 r34  
    218218    procedure FilterList(AName: string; Items: TAcronymMeanings);
    219219    function AddAcronym(AcronymName, MeaningName: string): TAcronymMeaning;
     220    procedure RemoveMeaning(Meaning: TAcronymMeaning);
    220221    procedure RemoveAcronym(AcronymName, MeaningName: string);
    221222    procedure AssignToList(List: TListObject);
     
    772773  LastId := 0;
    773774  for I := 0 to Count - 1 do begin
    774     if TAcronymCategory(Items[I]).Id > LastId then LastId := TAcronymCategory(Items[I]).Id;
     775    if TAcronymMeaning(Items[I]).Id > LastId then LastId := TAcronymMeaning(Items[I]).Id;
    775776  end;
    776777  // Add ID to new items without ID
    777778  for I := 0 to Count - 1 do begin
    778     if TAcronymCategory(Items[I]).Id = 0 then begin
     779    if TAcronymMeaning(Items[I]).Id = 0 then begin
    779780      Inc(LastId);
    780       TAcronymCategory(Items[I]).Id := LastId;
     781      TAcronymMeaning(Items[I]).Id := LastId;
    781782    end;
    782783  end;
     
    875876  I: Integer;
    876877begin
    877   if Assigned(Acronym) then
    878     Acronym.Meanings.Remove(Self);
    879878  for I := 0 to Categories.Count - 1 do
    880879    TAcronymCategory(Categories[I]).AcronymMeanings.Remove(Self);
     
    13701369end;
    13711370
     1371procedure TAcronymDb.RemoveMeaning(Meaning: TAcronymMeaning);
     1372var
     1373  Acronym: TAcronym;
     1374begin
     1375  Acronym := Meaning.Acronym;
     1376  Acronym.Meanings.Remove(Meaning);
     1377  if Acronym.Meanings.Count = 0 then
     1378    Acronyms.Remove(Acronym);
     1379  Modified := True;
     1380end;
     1381
    13721382procedure TAcronymDb.RemoveAcronym(AcronymName, MeaningName: string);
    13731383var
     
    13781388  if Assigned(Acronym) then begin
    13791389    Meaning := Acronym.Meanings.SearchByName(MeaningName);
    1380     if Assigned(Meaning) then begin
    1381       Acronym.Meanings.Remove(Meaning);
    1382       if Acronym.Meanings.Count = 0 then
    1383         Acronyms.Remove(Acronym);
    1384     end;
    1385   end;
    1386   Modified := True;
     1390    if Assigned(Meaning) then RemoveMeaning(Meaning);
     1391  end;
    13871392end;
    13881393
Note: See TracChangeset for help on using the changeset viewer.