Again: Cancelling TWAIN scan hangs Script-Fu
"Hermann Josef Hill" <[email protected]>
| Newsgroups | gmane.comp.video.gimp.windows.devel |
|---|---|
| Message-ID | <001801c25bcf$ce445da0$6464a8c0@notebook> |
Hi again,
I solved my compiler problem from yesterday (maybe I shouldn't try to
compile things when I'm half asleep ;-) ) - and solved the original problem
too.
Here is the diff for my (preliminary) solution:
--- snip --- snip --- snip --- snip --- snip --- snip --- snip --- snip ---
snip --- snip --- snip --- snip ---
diff gimp-1.2.4/plug-ins/twain/tw_func.c GIMP_TWAIN/tw_func.c
886,892c886,888
< /* Disable the datasource, Close the Data source
< * and close the data source manager
< */
< LogMessage("CloseDSReq\n");
< disableDS(twSession);
< closeDS(twSession);
< closeDSM(twSession);
---
> LogMessage("CloseDSReq\n");
> // let the callback function do the job instead of shutting down
>
(*twSession->transferFunctions->postTxfrCb)(0,twSession->clientData);
diff gimp-1.2.4/plug-ins/twain/twain.c GIMP_TWAIN/twain.c
429c429,430
< getImage(twSession);
---
> if (!getImage(twSession))
> PostQuitMessage(255); // TODO: close TWAIN before bailing out
--- snip --- snip --- snip --- snip --- snip --- snip --- snip --- snip ---
snip --- snip --- snip --- snip ---
However, as the TODO comment indicates, the solution works, but there are
issues with it:
- when the user presses "Cancel" in the data source selection window, the
TWAIN driver isn't cleanly shut down.
- a design issue with the code in tw_func.c: is it permissible to call the
postTransfer callback function when there was no transfer?
- a follow up from the above issue - is it right to let the callback shut
down the TWAIN driver? Shouldn't the shutting down be handled in tw_func.c
and the callback do anything else that's necessary (i.e. the PostQuitMessage
call in the standard case)?
I think the whole plugin needs its structure changed, but right now I
haven't got the time to do it. However, I may have the time in a few days,
so if someone wants to discuss the above issues with me, I'd greatly
appreciate that.
Regards, Hermann
PS: If my patch is accepted, I'd also appreciate to hear that.