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
 Attempting to scan with nothing loaded hangs app
 New Topic  Reply to Topic
Author Previous Topic Topic Next Topic  

JonRobertson

USA
41 Posts

Posted - Oct 20 2011 :  17:12:42  Show Profile  Reply
I'm using a business card scanner and inadvertently called Acquire when there is nothing ready to scan. I get an External Exception C0000008. But the bigger problem is that the ImageEn code locks up. I'll start at imscan.IETW_Acquire:


    // shut everything down in the right sequence
    // these routines do nothing if the corresponding 'open' failed
    IETW_DisableSource(grec);
    IETW_CloseSource(grec);


IETW_DisableSource fails. IETW_CloseSource is then called. since nState = 5, IETW_DisableSource is called again. That then calls IETW_DS with MSG_DISABLEDS, which calls DSM_Entry.

At this point, my app locks up. The process is not completely locked up because a breakpoint in Classes.StdWndProc will break when I move the mouse over my form, etc. But DSM_Entry never returns and my UI is mostly unresponsive. (UI changes corresponding to mouse enter/exit/move/over related events occur. But buttons, menu items, and other visual controls do not receive focus.)

Is there anything else you need from me so this issue can be resolved?

Thanks

fab

1310 Posts

Posted - Oct 24 2011 :  00:08:10  Show Profile  Reply
Actually I don't know how to solve this problem. The external exception should come from the driver, and should not happen. The driver refuses to be disabled.

That is the unique right closing sequence. One try you should do is to force data source closing changing the code in this way:

IETW_DisableSource(grec);
nState := 4;
IETW_CloseSource(grec);

Please let me know what happens.
Go to Top of Page

JonRobertson

USA
41 Posts

Posted - Oct 25 2011 :  06:55:25  Show Profile  Reply
Here is a little more detail:

  • IETW_Acquire calls IETW_ModalEventLoop.

  • IETW_ModalEventLoop calls IETW_MessageHook.

  • While handling the MSG_XFERREADY message, fAborting is True, so IETW_DisableSource is called (with no exception occurring).

  • However, IETW_DS(..., MSG_DISABLEDS, ...) returns False so nState is left at 5. But no exception occurs during this call to IETW_DisableSource.

  • Once IETW_ModalEventLoop exits, IETW_Acquire calls IETW_DisableSource.

  • Since nState = 5, IETW_DS(..., MSG_DISABLEDS, ...) is called again, and this time the external exception occurs.


In IETW_DisableSource, I changed the code to set nState := 4 even if the call to IETW_DS returns False. So this:
if (nState = 5) and (IETW_DS(grec, DG_CONTROL, DAT_USERINTERFACE, MSG_DISABLEDS, @twUI)) then
  nState := 4;

is now this:
if nState = 5 then begin
  IETW_DS(grec, DG_CONTROL, DAT_USERINTERFACE, MSG_DISABLEDS, @twUI);
  nState := 4;
end;


IETW_DisableSource no longer sends MSG_DISABLEDS to the driver twice and I no longer receive the external exception.

Now the scan silently fails and I get a black image, which is better than the previous experience. Now I need to see if I can detect whether something is loaded in the scanner before calling Acquire.

Jon
Go to Top of Page

JonRobertson

USA
41 Posts

Posted - Oct 25 2011 :  07:03:28  Show Profile  Reply
Btw, fAborting is being set to True in IETW_XferReadyMulti in the "case rc of", when rc = TWRC_FAILURE.

In this scenario, MSG_DISABLEDS is sent twice. Do most drivers handle this without exception and thus this driver is poorly behaving? Or should ImageEn be altered to avoid sending MSG_DISABLEDS twice?

Now that the exception is not occurring, I confirmed that MIO.Acquire is returning False for my scenario, indicating that the scan did fail. That's good. ;)
Go to Top of Page

fab

1310 Posts

Posted - Oct 27 2011 :  08:12:03  Show Profile  Reply
It is ok, thank you! This change will be included in next minor release.
Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
Jump To: