Menu

#108 wrong unassigned connector error working without defaultconn

v2.0
open
nobody
Core (16)
5
2012-11-03
2006-09-21
No

Working without a DefaultConnector assigned, I've found
a problem when you use a TInstantReference by a
DbLookupComboBox and change its value: an "unassigned
connector" error raises, but the connector is assigned.
The problem is into TInstantRecordBuffer.RegisterField:
changing the object field by the lookupcombobox the new
undo mechanism try to register the field into
FieldBufferList.
Into RegisterField there are those lines:
VFieldBuffer.ClonedAttr :=
TInstantAttributeClass(VAttr.ClassType).Create(nil,nil);
Notice that Create don't pass Owner and Metadata!

but in presence of a TInstantReference the Owner is not
passed to Create method.

The next line calls TInstantReference.Assign: into this
method there is a test on Self.Connector but this test
raises the error, because it calls:
function TInstantComplex.GetConnector: TInstantConnector;
begin
if Assigned(Owner) then
Result := Owner.Connector
else
Result := nil;
InstantCheckConnector(Result);
end;
The Owner was not passed by RegisterField and
InstantCheckConnector raises an error because there
isn't a default connector assigned.

To replicate the problem make those steps in Intro demo:
1) set InstantBDEConnector1.IsDefault to False
2) change the line 65 of Main.pas
Person := TPerson.Create(InstantBDEConnector1);
3) change the line 78 of Main.pas
Company := TCompany.Create(InstantBDEConnector1);
4) CompanyEdit.dfm:
PersonsSelector.Connector = MainForm.InstantBDEConnector1
5) Add uses of Main in CompanyEdit.pas
6) Build, run, Add Company, Select a person from
combobox... boom!

Discussion


Log in to post a comment.

MongoDB Logo MongoDB