Note: You must be registered in order to post a reply. To register, click here. Registration is FREE!
T O P I C R E V I E W
JonRobertson
Posted - Oct 27 2011 : 05:37:37 CameraGetImages demo is throwing an Access Violation in Delphi XE with ImageEn 4.01. To reproduce:
Run the demo.
Select the Select Camera menu option.
Hit Escape or click Cancel.
Select the Select Camera menu option a second time.
Hit Escape or click Cancel.
The AV occurs in iewia.pas:TIEWia.GetItemProperty because item.This is nil. Line 2071 calls item.This.QueryInterface which throws an AV since item.This is nil. It seems that TIEWia.GetItemProperty should handle this condition.
It also seems that the demo's TMainForm.SelectCamera1Click event should not call FillFileNames if the user cancelled the dialog. If I change the event accordingly, the AV does not occur.
procedure TMainForm.SelectCamera1Click(Sender: TObject);
begin
if ImageEnView1.IO.SelectAcquireSource(ieaWIA) then
FillFileNames;
end;
2 L A T E S T R E P L I E S (Newest First)
JonRobertson
Posted - Oct 28 2011 : 14:04:52 I think my change is important in all cases. If the user has cancelled the dialog, then the user has cancelled the Select Camera action. So I'm wondering if the best fix is this:
procedure TMainForm.SelectCamera1Click(Sender: TObject);
begin
if ImageEnView1.IO.SelectAcquireSource(ieaWIA) then begin
TreeView1.Items.Clear; // <<<<< ADDED THIS!!!
FillFileNames;
end;
end;
Or perhaps just move TreeView1.Items.Clear to the top of FillFileNames, if the TreeView should always be cleared when FillFileNames is called.
The demos are very useful to a newbie learning how to use the components. Having demos that demonstrate "best practices" helps us learn the right way to use the components instead of the wrong way.
fab
Posted - Oct 28 2011 : 13:22:45 Actually there is a bug in the demo sample. The right code should be:
// Select camera (WIA source)
procedure TMainForm.SelectCamera1Click(Sender: TObject);
begin
TreeView1.Items.Clear; // <<<<< ADDED THIS!!!
ImageEnView1.IO.SelectAcquireSource(ieaWIA);
FillFileNames;
end;
In case user clicks Cancel button in the dialog the default device is anyway selected and retrieved. Your change is also right if you don't want to select a default device.