ImageEn for Delphi and C++ Builder ImageEn for Delphi and C++ Builder

 

ImageEn Forum
Profile    Join    Active Topics    Forum FAQ    Search this forumSearch
Forum membership is Free!  Click Join to sign-up
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 ImageEn Library for Delphi, C++ and .Net
 ImageEn and IEvolution Support Forum
 Access Violation in CameraGetImages demo
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

JonRobertson

USA
41 Posts

Posted - Oct 27 2011 :  05:37:37  Show Profile  Reply
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;

fab

1310 Posts

Posted - Oct 28 2011 :  13:22:45  Show Profile  Reply
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.
Go to Top of Page

JonRobertson

USA
41 Posts

Posted - Oct 28 2011 :  14:04:52  Show Profile  Reply
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.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: