Skip to content

Commit

Permalink
Check for correct system in UpdateDatabaseWithList. Optimization in A…
Browse files Browse the repository at this point in the history
…pplytranslationList. #20
  • Loading branch information
bero committed Dec 7, 2024
1 parent 06bb863 commit d365812
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 4 deletions.
2 changes: 2 additions & 0 deletions Source/BoldCoreConsts.pas
Original file line number Diff line number Diff line change
Expand Up @@ -362,7 +362,9 @@ interface
// BoldSystem
sReasonUnknown = 'Reason unknown';
sFailureMessage = '%s.%s failed: %s';
sObjectFromAnotherSystem = '%s Objects from wrong system passed to %s.';
sBoldObjectAssigned = '%s.Destroy: BoldObject assigned';
sLocatorNotFound = '%s.%s. Locator not found for ID: %s';
sNoSuchClass = '%s.%s: System contains no class named: %s';
sCannotCreateInexact = 'Can not create objects with approximate type. ID: %s Class: %s';
sClassDoesNotBelongHere = '%s.GetAllInClass: %s does not belong to this system';
Expand Down
19 changes: 15 additions & 4 deletions Source/BoldSystem.pas
Original file line number Diff line number Diff line change
Expand Up @@ -2541,6 +2541,12 @@ procedure TBoldSystem.UpdateDatabaseWithList(ObjectList: TBoldObjectList);
begin
if IsUpdatingDatabase then
raise EBold.CreateFmt(sUpdateDbRentry, []);
if BoldSystemCount > 1 then
begin
for var BO in ObjectList do
if BO.BoldSystem <> self then
raise EBold.CreateFmt(sObjectFromAnotherSystem, [classname, 'UpdateDatabaseWithList']);
end;
SystemPersistenceHandler.UpdateDatabaseWithList(ObjectList);
if (DirtyObjects.Count > 0) then
fOldValueHandler.PurgeEqualValues
Expand Down Expand Up @@ -9898,16 +9904,21 @@ procedure TBoldSystem_Proxy.ApplytranslationList(
var
I: Integer;
Locator: TBoldObjectLocator;
Id: TBoldObjectId;
begin
if IdTranslationList.Count = 0 then
exit;
for I := 0 to IdTranslationList.Count - 1 do
begin
if Assigned(IdTranslationList.OldIDs[I]) then
Id := IdTranslationList.OldIDs[I];
if Assigned(Id) then
begin
Locator := ProxedSystem.Locators.LocatorByID[IdTranslationList.OldIDs[I]];
if Assigned(IdTranslationList.NewIDs[I]) then
ProxedSystem.Locators.UpdateId(Locator, IdTranslationList.NewIds[i])
Locator := ProxedSystem.Locators.LocatorByID[Id];
if not Assigned(Locator) then
raise EBoldInternal.CreateFmt(sLocatorNotFound, [ClassName, 'ApplytranslationList', Id.AsString]);
Id := IdTranslationList.NewIDs[I];
if Assigned(Id) then
ProxedSystem.Locators.UpdateId(Locator, Id)
end
else
begin
Expand Down

0 comments on commit d365812

Please sign in to comment.