From 84b624c99aea22406a6444749d15b9073b478963 Mon Sep 17 00:00:00 2001 From: Roland Bengtsson Date: Fri, 6 Dec 2024 23:54:44 +0200 Subject: [PATCH] Removed conditional for broadcast, now it is merged as default behaviour. #20 --- Source/Bold.inc | 4 - Source/BoldAFPDefault.pas | 4 +- Source/BoldConstraintValidator.pas | 4 - Source/BoldCoreConsts.pas | 1 - Source/BoldElements.pas | 7 +- Source/BoldLogHandlerForm.pas | 24 ++++-- Source/BoldObjectListControllers.pas | 108 ++++++++++++------------ Source/BoldObjectRepresentationJson.pas | 2 +- Source/BoldOcl.pas | 2 +- Source/BoldOclPropEditor.pas | 2 +- Source/BoldRegionDefinitionParser.pas | 2 +- Source/BoldSamplesReg.pas | 6 +- Source/BoldSmallLogFrame.pas | 2 +- Source/BoldSystem.pas | 56 +++++++----- Source/BoldSystemRT.pas | 3 +- Source/BoldTypeNameSelector.pas | 10 ++- Source/BoldUMLModelEditForm.pas | 5 +- Source/BoldUMLModelEditFormCx.pas | 2 +- Source/BoldUMLModelSupport.pas | 70 +-------------- Source/BoldUMLModelValidationFormCx.pas | 6 +- 20 files changed, 134 insertions(+), 186 deletions(-) diff --git a/Source/Bold.inc b/Source/Bold.inc index 5af9e7e5..2bcb283e 100644 --- a/Source/Bold.inc +++ b/Source/Bold.inc @@ -203,9 +203,6 @@ Illegal symbol combination //Adds brJson StringRepresentation via BoldObjectRepresentationJson unit {$DEFINE BoldJson} -// BoldSystem broadcasts member events - allows getting events from all objects and their members by only placing one subscription on system -{$DEFINE BoldSystemBroadcastMemberEvents} - // NoEnsureEnclosure skips EnsureEnclosure call in UpdateDatabase, use NoEnsureEnclosure if objects passed to UpdateDatabase are already enclosed {.$DEFINE NoEnsureEnclosure} @@ -237,6 +234,5 @@ Illegal symbol combination {$UNDEF IDServer} {$UNDEF NoNegativeDates} {$UNDEF ConvertZeroDateToDateNil} - {$UNDEF BoldSystemBroadcastMemberEvents} {$ENDIF} diff --git a/Source/BoldAFPDefault.pas b/Source/BoldAFPDefault.pas index e68ac856..eb0f1055 100644 --- a/Source/BoldAFPDefault.pas +++ b/Source/BoldAFPDefault.pas @@ -952,14 +952,14 @@ function TBoldDefaultObjectAutoFormProvider.GetGoodStringRepresentationForSingle ClassTypeInfo := (MemberRTInfo as TBoldRoleRTInfo).ClassTypeInfoOfOtherEnd; if ClassTypeInfo.DefaultStringRepresentation = '' then begin - for i := 0 to ClassTypeInfo.AllMembers.Count - 1 do + for i := 0 to ClassTypeInfo.AllMembersCount - 1 do if ClassTypeInfo.AllMembers[i].BoldType.ExpressionName = 'String' then // do not localize begin Result := ClassTypeInfo.AllMembers[i].ExpressionName; exit; end; - for i := 0 to ClassTypeInfo.AllMembers.Count - 1 do + for i := 0 to ClassTypeInfo.AllMembersCount - 1 do if ClassTypeInfo.AllMembers[i] is TBoldAttributeRTInfo then begin Result := ClassTypeInfo.AllMembers[i].ExpressionName; diff --git a/Source/BoldConstraintValidator.pas b/Source/BoldConstraintValidator.pas index 9c5e1f03..2991679f 100644 --- a/Source/BoldConstraintValidator.pas +++ b/Source/BoldConstraintValidator.pas @@ -351,11 +351,7 @@ procedure TBoldConstraintValidator.Changed; case ValidationMode of vmManual:; vmOnModify: - {$IFDEF BoldSystemBroadcastMemberEvents} BoldSystem.AddSubscription(Subscriber, beCompleteModify, beCompleteModify); - {$ELSE} - raise Exception.CreateFmt(sVMOnModifyRequirements, [ClassName]); - {$ENDIF} vmPreUpdate: BoldSystem.OnPreUpdate := PreUpdate; end; diff --git a/Source/BoldCoreConsts.pas b/Source/BoldCoreConsts.pas index 038d45e7..4729e727 100644 --- a/Source/BoldCoreConsts.pas +++ b/Source/BoldCoreConsts.pas @@ -1136,7 +1136,6 @@ interface sUMLGenInterface = 'Generate Persistence Interfaces'; // BoldConstraintValidator - sVMOnModifyRequirements = '%s: vmOnModify mode requires BoldSystemBroadcastMemberEvents conditional define.'; sConstraints = 'Constraints'; implementation diff --git a/Source/BoldElements.pas b/Source/BoldElements.pas index dba10f59..e97cff15 100644 --- a/Source/BoldElements.pas +++ b/Source/BoldElements.pas @@ -56,6 +56,7 @@ interface befInDelayDestructionList = BoldElementFlag13; befDiscarding = BoldElementFlag14; befDeleting = BoldElementFlag15; + befCreating = BoldElementFlag16; {flags for BoldMember} befIsNull = BoldElementFlag4; @@ -711,8 +712,8 @@ procedure TBoldElement.CompareTypeError(CompType: TBoldCompareType; BoldElement: ElementName := BoldElement.ClassName else ElementName := 'nil'; - - raise EBold.CreateFmt(sInvalidCompareType, [ClassName, + + raise EBold.CreateFmt(sInvalidCompareType, [ClassName, GetEnumName(TypeInfo(TBoldCompareType), Ord(CompType)), ElementName]); end; @@ -1175,7 +1176,7 @@ procedure InitDebugMethods; List: TBoldExternalVariableList; begin // Used to force compiler to link AsCommaText, so it can be used in debugging - exit; + exit; List := nil; List.AsCommaText; end; diff --git a/Source/BoldLogHandlerForm.pas b/Source/BoldLogHandlerForm.pas index e8ba541d..12713896 100644 --- a/Source/BoldLogHandlerForm.pas +++ b/Source/BoldLogHandlerForm.pas @@ -30,6 +30,7 @@ TBoldLogHandlerReceiver = class(TInterfacedObject, IBoldLogReceiver) procedure SetProgressMax(const Value: integer); procedure ProcessInterruption; public + procedure AfterConstruction; override; destructor Destroy; override; procedure Clear; procedure Hide; @@ -42,6 +43,8 @@ TBoldLogHandlerReceiver = class(TInterfacedObject, IBoldLogReceiver) procedure SaveLog; end; +function BoldLogForm: IBoldLogReceiver; + implementation uses @@ -54,8 +57,21 @@ implementation var LogHandlerForm: TBoldLogHandlerReceiver; +function BoldLogForm: IBoldLogReceiver; +begin + if not Assigned(LogHandlerForm) then + LogHandlerForm := TBoldLogHandlerReceiver.Create; + result := LogHandlerForm; +end; + { TBoldLogHandlerReceiver } +procedure TBoldLogHandlerReceiver.AfterConstruction; +begin + inherited; + BoldLog.RegisterLogReceiver(self as IBoldLogReceiver); +end; + procedure TBoldLogHandlerReceiver.Clear; begin LogForm.Clear; @@ -155,12 +171,4 @@ procedure TBoldLogHandlerReceiver.Sync; Application.ProcessMessages; end; -initialization -// LogHandlerForm := TBoldLogHandlerReceiver.Create; -// BoldLog.RegisterLogReceiver(LogHandlerForm as IBoldLogReceiver); - -finalization -// if Assigned(LogHandlerForm) then -// BoldLog.UnregisterLogReceiver(LogHandlerForm as IBoldLogReceiver); - end. \ No newline at end of file diff --git a/Source/BoldObjectListControllers.pas b/Source/BoldObjectListControllers.pas index 4026d2b3..3c5dd5b7 100644 --- a/Source/BoldObjectListControllers.pas +++ b/Source/BoldObjectListControllers.pas @@ -93,7 +93,7 @@ TBoldClassListController = class(TBoldObjectListController) public constructor Create(OwningList: TBoldObjectList); destructor Destroy; override; - procedure ReceiveClassEvent(BoldObject: TBoldObject; Event: TBoldEvent); + procedure ReceiveClassEvent(BoldElement: TBoldDomainElement; Event: TBoldEvent; const Args: array of const); function ProxyInterface(const IId: TGUID; Mode: TBoldDomainElementProxyMode; out Obj): Boolean; override; function AtTime(Time: TBoldTimeStampType): TBoldMember; override; function HandlesAtTime: Boolean; override; @@ -393,16 +393,10 @@ procedure TBoldObjectListController._ReceiveObjectDeleted( var DeletedLocator: TBoldObjectLocator; begin - assert(originator is TBoldObjectList); case OriginalEvent of - beLocatorDestroying, - beItemDeleted: + beLocatorDestroying, beObjectDeleted: begin - assert(High(Args) = 0); - assert(Args[0].vType = vtObject); - Assert(Args[0].VObject is TBoldObjectLocator); - DeletedLocator := TBoldObjectLocator(Args[0].VObject); - Assert(not Assigned(OwningList.Boldtype) or DeletedLocator.BoldClassTypeInfo.BoldIsA(OwningObjectList.ListElementTypeInfo)); + DeletedLocator := (Originator as TBoldObject).BoldObjectLocator; RemoveLocator(DeletedLocator); end; beDestroying: @@ -434,13 +428,13 @@ procedure TBoldObjectListController.SubscribeToObjectDeleted(Locator: TBoldObjec // Subscribe to ClassList instead of System to avoid having all subscriptions on system. // When object is deleted, system sends beObjectDeleted, ClassList receives it and sends beItemDeleted instead if OwningObjectList.SubscribeToObjectsInList then - ClassList.AddSmallSubscription(FSubscriber, [beLocatorDestroying, beDestroying, beItemDeleted]) + ClassList.AddSmallSubscription(FSubscriber, [beLocatorDestroying, beObjectDeleted{, beDestroying}]) else ClassList.AddSmallSubscription(FSubscriber, [beLocatorDestroying]); end else if OwningObjectList.SubscribeToObjectsInList then - ClassList.AddSmallSubscription(FSubscriber, [beDestroying, beItemDeleted]); + ClassList.AddSmallSubscription(FSubscriber, [beDestroying, beObjectDeleted]); end; procedure TBoldObjectListController.DropSubscriptions; @@ -664,68 +658,70 @@ procedure TBoldClassListController.MarkListCurrent; type TBoldObjectListAccess = class(TBoldObjectList); -procedure TBoldClassListController.ReceiveClassEvent(BoldObject: TBoldObject; Event: TBoldEvent); +procedure TBoldClassListController.ReceiveClassEvent(BoldElement: TBoldDomainElement; Event: TBoldEvent; const Args: array of const); var List: TBoldObjectListAccess; begin - List := TBoldObjectListAccess(OwningList); if Assigned(fSuperClassController) then - fSuperClassController.ReceiveClassEvent(BoldObject, Event); - case Event of - beObjectCreated: - begin - inc(fLoadedObjectCount); - if Owninglist.BoldPersistenceState in [bvpsCurrent, bvpsTransient] then + fSuperClassController.ReceiveClassEvent(BoldElement, Event, args); + List := TBoldObjectListAccess(OwningList); + if BoldElement is TBoldObject then + begin + var BoldObject: TBoldObject; + BoldObject := BoldElement as TBoldObject; + case Event of + beObjectCreated: begin - AddLocator(BoldObject.BoldObjectLocator); - Owninglist.Invalidate; + inc(fLoadedObjectCount); + if not List.BoldPersistenceStateIsInvalid then + begin + AddLocator(BoldObject.BoldObjectLocator); + if List.HasSubscribers then + List.Publisher.SendEvent(beValueInvalid); + end; end; - end; - beObjectDeleted: - begin - Dec(fLoadedObjectCount); - if Owninglist.BoldPersistenceState in [bvpsCurrent, bvpsTransient] then + beObjectDeleted: begin - if ClassTypeInfo.Persistent and BoldSystem.BoldPersistent then - LocatorList.Remove(BoldObject.BoldObjectLocator); - Owninglist.Invalidate; + Dec(fLoadedObjectCount); + LocatorList.Remove(BoldObject.BoldObjectLocator); + if not List.BoldPersistenceStateIsInvalid then + begin + // if ClassTypeInfo.Persistent and BoldSystem.BoldPersistent then + // Assert(LocatorList.Includes(BoldObject.BoldObjectLocator)); + if List.HasSubscribers then + List.Publisher.SendEvent(beValueInvalid); + end; end; - end; - beObjectFetched: - begin - inc(fLoadedObjectCount); - if Owninglist.BoldPersistenceState in [bvpsCurrent, bvpsTransient] then + beObjectFetched: begin - if not LocatorList.LocatorInList[BoldObject.BoldObjectLocator] then - AddLocator(BoldObject.BoldObjectLocator); - if (Owninglist.BoldPersistenceState = bvpsTransient) and (fLoadedObjectCount = count) then - MarkListCurrent; + inc(fLoadedObjectCount); + if not List.BoldPersistenceStateIsInvalid then + begin + if not LocatorList.LocatorInList[BoldObject.BoldObjectLocator] then + AddLocator(BoldObject.BoldObjectLocator); + if (List.BoldPersistenceState = bvpsTransient) and (fLoadedObjectCount = count) then + MarkListCurrent; + end; end; - end; - beObjectUnloaded: - begin - if not BoldObject.BoldObjectIsDeleted then + beObjectUnloaded: begin - Dec(fLoadedObjectCount); - if Owninglist.BoldPersistenceState in [bvpsCurrent, bvpsTransient] then + if not BoldObject.BoldObjectIsDeleted then begin - SetPersistenceState(bvpsTransient); - if list.HasSubscribers then - OwningList.SendEvent(beValueInvalid); + Dec(fLoadedObjectCount); + if not List.BoldPersistenceStateIsInvalid then + begin + SetPersistenceState(bvpsTransient); + if list.HasSubscribers then + List.Publisher.SendEvent(beValueInvalid); + end; end; end; end; end; if List.HasSubscribers then - case event of - beObjectCreated: List.Publisher.SendExtendedEvent(OwningList, beItemAdded, [BoldObject.BoldObjectLocator]); - beObjectDeleted: List.Publisher.SendExtendedEvent(OwningList, beItemDeleted, [BoldObject.BoldObjectLocator]); - beObjectFetched: List.Publisher.SendExtendedEvent(OwningList, beObjectFetched, [BoldObject.BoldObjectLocator]); - beObjectUnloaded: List.Publisher.SendExtendedEvent(OwningList, beObjectUnloaded, [BoldObject.BoldObjectLocator]); - beLocatorDestroying: List.Publisher.SendExtendedEvent(OwningList, beLocatorDestroying, [BoldObject.BoldObjectLocator]) - else - raise EBoldInternal.CreateFmt('%s.ReceiveClassEvent: Unknown event: %d', [ClassName, Event]); - end; + begin + List.Publisher.SendExtendedEvent(BoldElement, Event, Args); + end; end; procedure TBoldClassListController.RemoveByIndex(index: Integer); diff --git a/Source/BoldObjectRepresentationJson.pas b/Source/BoldObjectRepresentationJson.pas index 3cfecea1..7286c597 100644 --- a/Source/BoldObjectRepresentationJson.pas +++ b/Source/BoldObjectRepresentationJson.pas @@ -610,7 +610,7 @@ function TBoldElementJsonConverter.CreateJsonForBoldObject(aBoldObject: TBoldObj //js.Add('id',StrToInt(aBoldObject.BoldObjectLocator.BoldObjectID.AsString)); //Result.Add('id',aBoldObject.BoldMemberByExpressionName['objectGUID'].AsString); - for I := 0 to aBoldObject.BoldClassTypeInfo.AllMembers.Count - 1 do + for I := 0 to aBoldObject.BoldClassTypeInfo.AllMembersCount - 1 do try vBoldMember := aBoldObject.BoldMembers[i]; vMemberRTInfo := vBoldMember.BoldMemberRTInfo; diff --git a/Source/BoldOcl.pas b/Source/BoldOcl.pas index 2fa0134f..b2d0124a 100644 --- a/Source/BoldOcl.pas +++ b/Source/BoldOcl.pas @@ -245,7 +245,7 @@ procedure TBoldOcl.CalculateMaxMemberNameLength; begin ClassInfo := fSystemTypeInfo.TopSortedClasses[i]; vLength := 0; - for j := 0 to ClassInfo.AllMembers.Count - 1 do + for j := 0 to ClassInfo.AllMembersCount - 1 do vLength := Max(vLength, Length(ClassInfo.AllMembers[j].ExpressionName)); fMaxMemberNameArray[i] := vLength; end; diff --git a/Source/BoldOclPropEditor.pas b/Source/BoldOclPropEditor.pas index ffc9ff6e..a6641d54 100644 --- a/Source/BoldOclPropEditor.pas +++ b/Source/BoldOclPropEditor.pas @@ -542,7 +542,7 @@ procedure TBoldOclPropEditForm.MemberHelp(Ocl: String); if ExpressionType is TBoldClasstypeInfo then begin ClassInfo := ExpressionType as TBoldClasstypeInfo; - for I := 0 to ClassInfo.AllMembers.Count - 1 do + for I := 0 to ClassInfo.AllMembersCount - 1 do begin Member := ClassInfo.AllMembers[I]; if not ShowDerived and Member.IsDerived then continue; diff --git a/Source/BoldRegionDefinitionParser.pas b/Source/BoldRegionDefinitionParser.pas index c6b520ec..ad111624 100644 --- a/Source/BoldRegionDefinitionParser.pas +++ b/Source/BoldRegionDefinitionParser.pas @@ -124,7 +124,7 @@ procedure TBoldRegionParser.GenerateDefaultRegions; DefaultRegion := DefaultCore.EnsuredConcreteDefinition(ClassTypeInfo, existed); if not existed then begin - for MemberIx := 0 to ClassTypeInfo.AllMembers.Count-1 do + for MemberIx := 0 to ClassTypeInfo.AllMembersCount-1 do begin MemberRTInfo := ClassTypeInfo.AllMembers[MemberIx]; if MemberRTInfo.IsAttribute then diff --git a/Source/BoldSamplesReg.pas b/Source/BoldSamplesReg.pas index c1e28b46..3945281f 100644 --- a/Source/BoldSamplesReg.pas +++ b/Source/BoldSamplesReg.pas @@ -72,9 +72,9 @@ procedure RegisterEditors; procedure Register; begin - RegisterComponentsOnPalette; - RegisterBoldActions; - RegisterEditors; + RegisterComponentsOnPalette; + RegisterBoldActions; + RegisterEditors; end; { TTextFileProperty } diff --git a/Source/BoldSmallLogFrame.pas b/Source/BoldSmallLogFrame.pas index 3965759a..2f81d628 100644 --- a/Source/BoldSmallLogFrame.pas +++ b/Source/BoldSmallLogFrame.pas @@ -258,7 +258,7 @@ procedure TBoldLogFrame.btnStopClick(Sender: TObject); procedure TBoldLogFrame.ProcessInterruption; begin - application.ProcessMessages; + Application.ProcessMessages; end; procedure TBoldLogFrame.Sync; diff --git a/Source/BoldSystem.pas b/Source/BoldSystem.pas index b1653b2c..e780a759 100644 --- a/Source/BoldSystem.pas +++ b/Source/BoldSystem.pas @@ -673,6 +673,7 @@ TBoldObject = class(TBoldDomainElement) property BoldObjectIsDeleted: Boolean read GetBoldObjectIsDeleted; property BoldObjectExists: Boolean read GetBoldObjectExists; property Touched: Boolean index befTouched read GetElementFlag; + property IsCreating: Boolean index befCreating read GetElementFlag write SetElementFlag; property Discarding: Boolean index befDiscarding read GetElementFlag write SetElementFlag; property Deleting: Boolean index befDeleting read GetElementFlag write SetElementFlag; property DeletingOrDeletingByDiscard: Boolean read GetDeletingOrDeletingByDiscard; @@ -1263,6 +1264,7 @@ TBoldListController = class(TBoldAbstractController) function GetIsEmpty: Boolean; virtual; public constructor Create(OwningList: TBoldList); virtual; + function AssertIntegrity: Boolean; override; procedure AddElement(Element: TBoldElement); virtual; abstract; function GetElement(index: Integer): TBoldElement; virtual; abstract; function IncludesElement(Item: TBoldElement): Boolean; virtual; abstract; @@ -1275,6 +1277,7 @@ TBoldListController = class(TBoldAbstractController) property Count: integer read GetCount; property IsEmpty: Boolean read GetIsEmpty; property Capacity: integer read GetCapacity write SetCapacity; + property Elements[index: Integer]: TBoldElement read GetElement write SetElement; default; end; {---TBoldAbstractObjectListController---} @@ -2212,7 +2215,7 @@ function TBoldMember.GetPSStateIsInvalid: Boolean; function TBoldObject.GetBoldMemberCount: Integer; begin - Result := BoldClassTypeInfo.AllMembers.Count; + Result := BoldClassTypeInfo.AllMembersCount; end; function TBoldObject.GetBoldMemberAssigned(Index: integer): Boolean; @@ -2813,7 +2816,7 @@ procedure TBoldSystem.DestroyObject(BoldObject: TBoldObject); // If we got an exception duriung destoy, we might get an half uninitialized BoldObject without Locator next time. if Assigned(aLocator) then //PATCH begin - TBoldClassListController(Classes[aLocator.BoldClassTypeInfo.TopSortedIndex].ObjectListController).ReceiveClassEvent(BoldObject, beLocatorDestroying); + TBoldClassListController(Classes[aLocator.BoldClassTypeInfo.TopSortedIndex].ObjectListController).ReceiveClassEvent(BoldObject, beLocatorDestroying, []); SendExtendedEvent(beLocatorDestroying, [aLocator]); aLocator.UnloadBoldObject; Locators.Remove(aLocator); @@ -2832,22 +2835,22 @@ procedure TBoldSystem.ReceiveEventFromOwned(originator: TObject; var ClassList: TBoldObjectList; begin - if (originalEvent in [beObjectCreated, beObjectDeleted, beObjectFetched, beObjectUnloaded, beCompleteModify]) - and (originator is TBoldObject) then + if Assigned(fClasses) then begin - if originalEvent in [beObjectCreated, beObjectDeleted, beObjectFetched, beObjectUnloaded] then + ClassList := nil; + if (originator is TBoldMember) then begin + if not Assigned(TBoldMember(Originator).OwningObject) then + exit; + ClassList := Classes[TBoldMember(Originator).OwningObject.BoldClassTypeInfo.TopSortedIndex]; + end + else + if (originator is TBoldObject) then ClassList := Classes[TBoldObject(Originator).BoldClassTypeInfo.TopSortedIndex]; - Assert(ClassList.ObjectListController is TBoldClassListController); - TBoldClassListController(ClassList.ObjectListController).ReceiveClassEvent(TBoldObject(Originator), OriginalEvent); - end; - SendExtendedEvent(originalEvent, [originator]); - end - else -{$IFDEF BoldSystemBroadcastMemberEvents} + TBoldClassListController(ClassList.ObjectListController).ReceiveClassEvent(Originator as TBoldDomainElement, OriginalEvent, Args); if (originalEvent in beBroadcastMemberEvents) and ((Originator is TBoldObject) or (Originator is TBoldMember) and (TBoldMember(Originator).OwnedByObject)) then Publisher.SendExtendedEvent(Originator, originalEvent, Args); -{$ENDIF} + end; end; procedure TBoldSystem.ReceiveFromPersistenceController(Originator: TObject; @@ -3841,11 +3844,9 @@ procedure TBoldObject.ReceiveEventFromOwned(originator: TObject; originalEvent: if (BoldExistenceState = besExisting) and (originalEvent in beValueEvents) then SendExtendedEvent(beMemberChanged, [Originator]); -{$IFDEF BoldSystemBroadcastMemberEvents} if (BoldExistenceState = besExisting) and (originalEvent in beBroadcastMemberEvents) then BoldSystem.ReceiveEventFromOwned(Originator, OriginalEvent, Args); // broadcast member events through BoldSystem -{$ENDIF} end; function TBoldObject.ReceiveQueryFromOwned(Originator: TObject; @@ -3987,7 +3988,7 @@ function TBoldObject.CheckLinks(index: Integer): Boolean; MemberRTInfo: TBoldmemberRTInfo; begin Result := True; - for I := 0 to BoldClassTypeInfo.AllMembers.Count - 1 do + for I := 0 to BoldClassTypeInfo.AllMembersCount - 1 do begin MemberRTInfo := BoldClassTypeInfo.AllMembers[i]; if (I <> index) and not MemberRTInfo.IsDerived then @@ -4347,8 +4348,13 @@ procedure TBoldObject.EndCreate; else SetBoldPersistenceState(bvpsTransient); try - CompleteCreate; - SendEvent(beCompleteModify); + IsCreating := true; + try + CompleteCreate; + SendEvent(beCompleteModify); + finally + IsCreating := false; + end; except SetBoldExistenceState(besNotCreated); SetBoldPersistenceState(bvpsCurrent); @@ -4906,7 +4912,7 @@ procedure TBoldObject.Invalidate; if BoldDirty then raise EBold.CreateFmt(sCannotInvalidateDirtyObject, [classname]); - for i := 0 to BoldClassTypeInfo.AllMembers.Count - 1 do + for i := 0 to BoldClassTypeInfo.AllMembersCount - 1 do if BoldClassTypeInfo.AllMembers[i].Persistent and BoldMembers[i].BoldPersistent then BoldMembers[i].Invalidate; @@ -9223,6 +9229,18 @@ constructor TBoldListController.Create(OwningList: TBoldList); fOwningList := OwningList; end; +function TBoldListController.AssertIntegrity: Boolean; +var + i: integer; +begin + for i := 0 to Count-1 do + begin + self[i].DebugInfo; + Assert(self[i] is TBoldElement); + end; + result := true; +end; + function TBoldListController.CreateNew: TBoldElement; begin raise EBold.Create(sCannotCreateNewElement); diff --git a/Source/BoldSystemRT.pas b/Source/BoldSystemRT.pas index 0614a42d..178d6f00 100644 --- a/Source/BoldSystemRT.pas +++ b/Source/BoldSystemRT.pas @@ -1260,7 +1260,8 @@ constructor TBoldClassTypeInfo.Create(SystemTypeInfo: TBoldSystemTypeInfo; moldC FAllRoles.OwnsEntries := false; fMethods := TBoldMethodRTInfoList.Create; fSubClasssesBoldClassTypeInfoList := TBoldClassTypeInfoList.Create; - fSubClasssesBoldClassTypeInfoList.OwnsEntries := false; + fSubClasssesBoldClassTypeInfoList.OwnsEntries := false; + fAllMembersCount := -1; Initialize(MoldClass, TypeNameDictionary, BoldObjectClasses, BoldObjectListClasses, SkipMembers); end; diff --git a/Source/BoldTypeNameSelector.pas b/Source/BoldTypeNameSelector.pas index b1abba64..bfd5ef23 100644 --- a/Source/BoldTypeNameSelector.pas +++ b/Source/BoldTypeNameSelector.pas @@ -41,7 +41,7 @@ TfrmBoldTypeNameSelector = class(TForm) procedure SetImageIndex(var Node: TTreeNode; NodeType: TNodeType); procedure SelectCurrentNode(CurrentStringValue: String; aNode: TTreeNode); public - function Select(var StringValue: String; SystemTypeInfo: TBoldSystemTypeInfo; ApprovedTypes: TBoldValueTypes): TModalResult; + function Select(var StringValue: String; ASystemTypeInfo: TBoldSystemTypeInfo; ApprovedTypes: TBoldValueTypes): TModalResult; end; implementation @@ -55,11 +55,13 @@ implementation { TfrmBoldTypeNameSelector } -function TfrmBoldTypeNameSelector.Select(var StringValue: String; SystemTypeInfo: TBoldSystemTypeInfo; ApprovedTypes: TBoldValueTypes): TModalResult; +function TfrmBoldTypeNameSelector.Select(var StringValue: String; ASystemTypeInfo: TBoldSystemTypeInfo; ApprovedTypes: TBoldValueTypes): TModalResult; begin Result := mrCancel; - fSystemTypeInfo := SystemTypeInfo; - GenerateNodes(SystemTypeInfo, ApprovedTypes, StringValue); + if not Assigned(ASystemTypeInfo) then + raise Exception.Create('SystemTypeInfo required.'); + fSystemTypeInfo := ASystemTypeInfo; + GenerateNodes(fSystemTypeInfo, ApprovedTypes, StringValue); if mrOK = ShowModal then begin StringValue := tvMetaTypes.Selected.Text; diff --git a/Source/BoldUMLModelEditForm.pas b/Source/BoldUMLModelEditForm.pas index 06aa32d5..6d1ec2ff 100644 --- a/Source/BoldUMLModelEditForm.pas +++ b/Source/BoldUMLModelEditForm.pas @@ -740,7 +740,8 @@ implementation BoldUMLPluginCallBacks, BoldUMLAbstractModelValidator, BoldRegistry, - BoldUMLModelEditorHandlesDataModule; + BoldUMLModelEditorHandlesDataModule, + BoldLogHandlerForm; {$R *.dfm} @@ -2587,7 +2588,7 @@ procedure TBoldModelEditFrm.FlattenClick(Sender: TObject); procedure TBoldModelEditFrm.Loggform1Click(Sender: TObject); begin - Boldlog.Show; + BoldLogForm.Show; end; procedure TBoldModelEditFrm.Tools1Click(Sender: TObject); diff --git a/Source/BoldUMLModelEditFormCx.pas b/Source/BoldUMLModelEditFormCx.pas index 838919e1..406f5b16 100644 --- a/Source/BoldUMLModelEditFormCx.pas +++ b/Source/BoldUMLModelEditFormCx.pas @@ -2908,7 +2908,7 @@ procedure TBoldModelEditFrmCx.LoadModelFromFile; procedure TBoldModelEditFrmCx.Loggform1Click(Sender: TObject); begin - Boldlog.Show; + BoldLogForm.Show; end; procedure TBoldModelEditFrmCx.Tools1Click(Sender: TObject); diff --git a/Source/BoldUMLModelSupport.pas b/Source/BoldUMLModelSupport.pas index fa651c4b..c1022949 100644 --- a/Source/BoldUMLModelSupport.pas +++ b/Source/BoldUMLModelSupport.pas @@ -42,9 +42,6 @@ TBoldCopyAndClone = class(TObject) TBoldUMLSupport = class(TObject) private class function NameInListExceptElement(Name: string; List: TUMLModelElementList; UMLElement: TUMLModelElement): Boolean; - {$IFNDEF BoldSystemBroadcastMemberEvents} - class procedure SubscribeToAllMembers(UMLElement: TUMLModelElement; Subscriber: TBoldSubscriber); - {$ENDIF} class function GetEnsuredPackage(Package: TUMLPackage; QualifiedPackageName: String): TUMLPackage; public class function UMLModelNameToUMLName(const ModelName: string): string; @@ -349,17 +346,7 @@ class procedure TBoldUMLSupport.RemoveTaggedValue(Element: TUMLModelElement; con if Assigned(TaggedValue) then TaggedValue.Delete; end; -{ -class procedure TBoldUMLSupport.SetDefaultBoldTaggedValues( - Element: TUMLModelElement); -var - i: integer; -begin - with BoldDefaultTaggedValueList.ListForClassName[UMLModelNameToUMLName(Element.BoldClassTypeInfo.ExpressionName)] do - for i := 0 to Count - 1 do - EnsuredTaggedValue(Element, BOLDTVPREFIX + Definition[i].Tag).value := Definition[i].DefaultValue; -end; -} + class procedure TBoldUMLSupport.StripToolId(Model: TUMLModel); var List: TUMLModelElementList; @@ -377,64 +364,9 @@ class procedure TBoldUMLSupport.StripToolId(Model: TUMLModel); List[i].Delete; end; -{$IFNDEF BoldSystemBroadcastMemberEvents} -class procedure TBoldUMLSupport.SubscribeToAllMembers(UMLElement: TUMLModelElement; Subscriber: TBoldSubscriber); -{var - m: integer; - MemberRTInfo: TBoldMemberRTInfo; - OtherEnd, RoleRTInfo: TBoldRoleRTInfo; - IsTaggedValue, Subscribe: Boolean;} -begin - UMLElement.AddSmallSubscription(subscriber, [beMemberChanged], breReEvaluate); -{ - // is it not possible to use the event beMemberChanged that is sent by an object. - IsTaggedValue := (UMLElement is TUMLTaggedValue); - for m := 0 to UMLElement.BoldMemberCount - 1 do - begin - MemberRTInfo := UMLElement.BoldClassTypeInfo.AllMembers[m]; - // for tagged values, only subscribe to the value! - if not MemberRTInfo.IsDerived and - (not IsTaggedValue) or (MemberRTInfo.ExpressionName = 'value') then - begin - if MemberRTInfo.IsAttribute then - begin - Subscribe := true; - end - else - begin - Assert(MemberRTInfo is TBoldRoleRTInfo); - RoleRTInfo := TBoldRoleRTInfo(MemberRTInfo); - OtherEnd := RoleRTInfo.RoleRTInfoOfOtherEnd; - Subscribe := - (RoleRTInfo.IsMultiRole or OtherEnd.IsSingleRole or not OtherEnd.IsNavigable) and - RoleRTInfo.IsNavigable and (RoleRTInfo.RoleType = rtRole); - end; - if Subscribe then - UMLElement.BoldMembers[m].DefaultSubscribe(Subscriber) - end; - end; - } -end; -{$ENDIF} - class procedure TBoldUMLSupport.SubscribeToEntireModel(UMLModel: TUMLModel; Subscriber: TBoldSubscriber); -{$IFNDEF BoldSystemBroadcastMemberEvents} -var - i: integer; - Parts: TUMLModelElementList; -{$ENDIF} begin -{$IFDEF BoldSystemBroadcastMemberEvents} UMLModel.BoldSystem.AddSmallSubscription(Subscriber, beBroadcastMemberEvents); -{$ELSE} - Parts := AllModelParts(UMLModel); - try - for i := 0 to Parts.Count - 1 do - SubscribeToAllMembers(Parts[i], Subscriber); - finally - Parts.Free; - end; -{$ENDIF} end; class function TBoldUMLSupport.UMLModelNameToUMLName(const ModelName: string): string; diff --git a/Source/BoldUMLModelValidationFormCx.pas b/Source/BoldUMLModelValidationFormCx.pas index 4e9099ad..2d299914 100644 --- a/Source/BoldUMLModelValidationFormCx.pas +++ b/Source/BoldUMLModelValidationFormCx.pas @@ -140,10 +140,8 @@ procedure TfrmValidationCx.tvViolationsCustomDrawCell( Sender: TcxCustomGridTableView; ACanvas: TcxCanvas; AViewInfo: TcxGridTableDataCellViewInfo; var ADone: Boolean); begin - ADone := not Assigned(BoldPlaceableSubscriber1.BoldHandle); - if not ADone then - if AViewInfo.GridRecord.Values[1] = 'Error' then - ACanvas.SetBrushColor($008080FF); + if AViewInfo.GridRecord.Values[1] = 'Error' then + ACanvas.SetBrushColor($008080FF); end; procedure TfrmValidationCx.tvViolationsDblClick(Sender: TObject);