View Issue Details
ID | Project | Category | View Status | Date Submitted | Last Update |
---|---|---|---|---|---|
0005590 | JEDI VCL | 00 JVCL Components | public | 2011-06-01 15:40 | 2011-06-09 22:13 |
Reporter | cguser | Assigned To | jfudickar | ||
Priority | normal | Severity | minor | Reproducibility | always |
Status | resolved | Resolution | fixed | ||
Product Version | Daily / GIT | ||||
Target Version | Fixed in Version | ||||
Summary | 0005590: TJvDBCustomSearchEdit.DoExit may cause AV | ||||
Description | On JvDBSearchEdit.pas, procedure DoExit may cause an AV if DataSet has just been closed before component lost it's focus. | ||||
Additional Information | Instead of procedure TJvDBCustomSearchEdit.DoExit; begin inherited DoExit; // On replace le texte sur l'enregistrement en cours if Assigned(FDataLink.DataSet) then Text := FDataLink.DataSet.FieldByName(DataField).AsString; end; this will account for DataSet's active state: procedure TJvDBCustomSearchEdit.DoExit; begin inherited DoExit; // On replace le texte sur l'enregistrement en cours if Assigned(FDataLink.DataSet) and FDataLink.DataSet.Active then Text := FDataLink.DataSet.FieldByName(DataField).AsString; end; PS: JvDBSearchEdit.pas rev 12461 | ||||
Tags | No tags attached. | ||||
|
Please provide the zipped sources of a sample application showing this |
2011-06-07 18:30
|
TestJvDBSearchEdit.7z (3,905 bytes) |
|
Done! The gist of it, new form, on the onclick event of a TButton, put the following code: TClientDataSet *cds = new TClientDataSet(this); TField *i = new TIntegerField(cds); i->FieldName = "Field1"; i->DataSet = cds; i->FieldKind = fkData; cds->CreateDataSet(); cds->Open(); TDataSource *ds = new TDataSource(this); ds->DataSet = cds; TJvDBSearchEdit *search = new TJvDBSearchEdit(this); search->Parent = this; search->DataSource = ds; search->DataField = "Field1"; search->SetFocus(); cds->Close(); SelectNext(search, true, true); // AV: Moving focus to next Ctrl |
|
Is this specific to C++Builder? |
|
Not that I'm aware of. The case as provided is a very simplified test code. On the real app, there was a TSpeedButton (focusless) that would commit data and close the dataset, before changing the active TabSheet (with a TJvDBSearchEdit on it) on a PageControl. When changing the active TabSheet, an AV was triggered on the TJvDBSearchEdit.DoExit because it's underlying dataset was no longer active. It's simply not intuitive for components to give access violations just by losing focus as in: if Assigned(FDataLink.DataSet) then Text := FDataLink.DataSet.FieldByName(DataField).AsString; This is just begging for trouble because FDataLink.DataSet may not be active (yet/)anymore. |
|
Done |
Date Modified | Username | Field | Change |
---|---|---|---|
2011-06-01 15:40 | cguser | New Issue | |
2011-06-07 18:03 | obones | Note Added: 0018640 | |
2011-06-07 18:03 | obones | Status | new => feedback |
2011-06-07 18:30 | cguser | File Added: TestJvDBSearchEdit.7z | |
2011-06-07 18:32 | cguser | Note Added: 0018643 | |
2011-06-08 10:12 | obones | Status | feedback => acknowledged |
2011-06-08 16:23 | obones | Note Added: 0018691 | |
2011-06-08 16:23 | obones | Status | acknowledged => feedback |
2011-06-08 17:24 | cguser | Note Added: 0018698 | |
2011-06-08 17:44 | obones | Status | feedback => acknowledged |
2011-06-09 22:13 | jfudickar | Note Added: 0018714 | |
2011-06-09 22:13 | jfudickar | Status | acknowledged => resolved |
2011-06-09 22:13 | jfudickar | Resolution | open => fixed |
2011-06-09 22:13 | jfudickar | Assigned To | => jfudickar |