From: Steven M. <sr...@us...> - 2005-11-24 22:49:57
|
Update of /cvsroot/instantobjects/Source/Core In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv12162 Modified Files: InstantPresentation.pas Log Message: 1. TInstantAccessor and TInstantObjectAccessor classes were modified to make TInstantObjectAccessor use a TObjectList of TInstantObjectReferences for the View list. The TInstantObjectReferences have their OwnsInstance properties set to true so that the view object instances are not destroyed before the view list is freed. 2. procedure TInstantCustomExposer.AccessorChanged - Reset the accessor View list before the dataset is refreshed. This fixes the AV's sometimes experienced when using InstantCustomExposer components, but should be regarded as an interim fix until root cause of problem is found. Index: InstantPresentation.pas =================================================================== RCS file: /cvsroot/instantobjects/Source/Core/InstantPresentation.pas,v retrieving revision 1.23 retrieving revision 1.24 diff -C2 -d -r1.23 -r1.24 *** InstantPresentation.pas 25 Oct 2005 06:21:13 -0000 1.23 --- InstantPresentation.pas 24 Nov 2005 22:49:45 -0000 1.24 *************** *** 65,74 **** FSorted: Boolean; FSubject: TObject; - FView: TList; FOnChange: TInstantChangeEvent; FOnCompare: TInstantCompareObjectsEvent; FOnLimit: TInstantLimitObjectsEvent; FOnProgress: TInstantProgressEvent; - procedure DestroyView; function GetAltered: Boolean; function GetHasSubject: Boolean; --- 65,72 ---- *************** *** 76,84 **** function GetObjectClass: TClass; function GetObjectClassName: string; - function GetObjectCount: Integer; function GetObjects(Index: Integer): TObject; function GetSubject: TObject; function GetTotalCount: Integer; - function GetView: TList; procedure SetContainerName(const Value: string); procedure SetLimited(Value: Boolean); --- 74,80 ---- *************** *** 90,105 **** procedure SetOnProgress(const Value: TInstantProgressEvent); procedure SetSorted(Value: Boolean); - property View: TList read GetView; protected function AddToView(AObject: TObject): Integer; function InsertInView(Index: Integer; AObject: TObject): Integer; function RemoveFromView(AObject: TObject): Integer; procedure Changed(ChangeType: TInstantChangeType); virtual; procedure DoLimit(AObject: TObject; var Accept: Boolean); procedure DoProgress(Sender: TObject; Count: Integer; var Continue: Boolean); function GetConnector: TInstantConnector; virtual; function GetMode: TInstantAccessMode; virtual; function IncludeObject(AObject: TObject): Boolean; function InternalAddObject(AObject: TObject): Integer; virtual; procedure InternalApplyChanges; virtual; procedure InternalClear; virtual; --- 86,105 ---- procedure SetOnProgress(const Value: TInstantProgressEvent); procedure SetSorted(Value: Boolean); protected + FView: TList; function AddToView(AObject: TObject): Integer; function InsertInView(Index: Integer; AObject: TObject): Integer; function RemoveFromView(AObject: TObject): Integer; procedure Changed(ChangeType: TInstantChangeType); virtual; + procedure DestroyView; virtual; procedure DoLimit(AObject: TObject; var Accept: Boolean); procedure DoProgress(Sender: TObject; Count: Integer; var Continue: Boolean); function GetConnector: TInstantConnector; virtual; function GetMode: TInstantAccessMode; virtual; + function GetObjectCount: Integer; virtual; + function GetView: TList; virtual; function IncludeObject(AObject: TObject): Boolean; function InternalAddObject(AObject: TObject): Integer; virtual; + function InternalAddToView(AObject: TObject): Integer; virtual; procedure InternalApplyChanges; virtual; procedure InternalClear; virtual; *************** *** 109,121 **** --- 109,127 ---- function InternalGetObjectCount: Integer; virtual; function InternalGetObjects(Index: Integer): TObject; virtual; + function InternalGetViewObjects(Index: Integer): TObject; virtual; function InternalIndexOfInstance(Instance: Pointer): Integer; virtual; function InternalIndexOfObject(AObject: TObject): Integer; virtual; + procedure InternalInsertInView(Index: Integer; AObject: TObject); virtual; function InternalInsertObject(Index: Integer; AObject: TObject): Integer; virtual; procedure InternalRefreshObjects; virtual; procedure InternalReleaseObject(AObject: TObject); virtual; + function InternalRemoveFromView(AObject: TObject): Integer; virtual; function InternalRemoveObject(AObject: TObject): Integer; virtual; + function InternalViewIndexOfInstance(Instance: Pointer): Integer; virtual; + function InternalViewIndexOfObject(AObject: TObject): Integer; virtual; property HasSubject: Boolean read GetHasSubject; property InternalObjects[Index: Integer]: TObject read InternalGetObjects; property InternalObjectCount: Integer read InternalGetObjectCount; + property View: TList read GetView; public constructor Create(ASubject: TObject); virtual; *************** *** 1114,1118 **** begin if Altered then ! Result := View[Index] else Result := InternalObjects[Index]; --- 1120,1124 ---- begin if Altered then ! Result := InternalGetViewObjects(Index) else Result := InternalObjects[Index]; *************** *** 1160,1164 **** begin if Altered then ! Result := View.IndexOf(Instance) else Result := InternalIndexOfInstance(Instance); --- 1166,1170 ---- begin if Altered then ! Result := InternalViewIndexOfInstance(Instance) else Result := InternalIndexOfInstance(Instance); *************** *** 1168,1172 **** begin if Altered then ! Result := View.IndexOf(AObject) else Result := InternalIndexOfObject(AObject); --- 1174,1178 ---- begin if Altered then ! Result := InternalViewIndexOfObject(AObject) else Result := InternalIndexOfObject(AObject); *************** *** 1207,1215 **** if Index < View.Count then begin ! View.Insert(Index, AObject); Result := Index; end else begin ! View.Add(AObject); Result := Pred(View.Count); end; --- 1213,1221 ---- if Index < View.Count then begin ! InternalInsertInView(Index, AObject); Result := Index; end else begin ! InternalAddToView(AObject); Result := Pred(View.Count); end; *************** *** 1230,1233 **** --- 1236,1244 ---- end; + function TInstantAccessor.InternalAddToView(AObject: TObject): Integer; + begin + Result := View.Add(AObject); + end; + procedure TInstantAccessor.InternalApplyChanges; begin *************** *** 1266,1269 **** --- 1277,1285 ---- end; + function TInstantAccessor.InternalGetViewObjects(Index: Integer): TObject; + begin + Result := View[Index]; + end; + function TInstantAccessor.InternalIndexOfInstance(Instance: Pointer): Integer; begin *************** *** 1279,1282 **** --- 1295,1304 ---- end; + procedure TInstantAccessor.InternalInsertInView(Index: Integer; AObject: + TObject); + begin + View.Insert(Index, AObject); + end; + function TInstantAccessor.InternalInsertObject(Index: Integer; AObject: TObject): Integer; *************** *** 1293,1296 **** --- 1315,1323 ---- end; + function TInstantAccessor.InternalRemoveFromView(AObject: TObject): Integer; + begin + Result := View.Remove(AObject); + end; + function TInstantAccessor.InternalRemoveObject(AObject: TObject): Integer; begin *************** *** 1298,1301 **** --- 1325,1339 ---- end; + function TInstantAccessor.InternalViewIndexOfInstance(Instance: Pointer): + Integer; + begin + Result := InternalViewIndexOfObject(Instance); + end; + + function TInstantAccessor.InternalViewIndexOfObject(AObject: TObject): Integer; + begin + Result := View.IndexOf(AObject); + end; + procedure TInstantAccessor.Refresh; begin *************** *** 1323,1327 **** function TInstantAccessor.RemoveFromView(AObject: TObject): Integer; begin ! Result := View.Remove(AObject); end; --- 1361,1365 ---- function TInstantAccessor.RemoveFromView(AObject: TObject): Integer; begin ! Result := InternalRemoveFromView(AObject); end; *************** *** 1445,1448 **** --- 1483,1492 ---- if Active then begin + // TODO: This Reset should not be necessary. + // It is a hack to avoid intermittent AVs. + // Further investigation is required to find + // the actual problem. - SM (24 Nov 2005) + Reset; + Refresh; DoAfterScroll; |