Modify

Opened 10 years ago

Closed 8 years ago

#838 closed Feature Request (Fixed)

Better COM error handling.

Reported by: PsaltyDS Owned by: Valik
Milestone: 3.3.7.19 Component: AutoIt
Version: Severity: None
Keywords: Cc:

Description

Ref: Forum post 649304http://www.autoitscript.com/forum/index.php?s=&showtopic=89906&view=findpost&p=649304

Request a standard and universally declared variable be included in the AutoIt environment (like $CmdLine and $CmdLineRaw) intended to hold the handle to the current COM Error Handler. Something like $oCOMError or $AutoItCOMErr.

Different UDFs using different naming conventions for the handler, leading to conflicts in proper handling. In the topic of the referenced post above, the error handlers for the _XMLDOMWrapper.au3 and IE.au3 UDFs collide.

If the AutoIt interpreter can cause something like $oAutoItCOMError to always reference the current error handler, like a ByRef, that would be great.

But if that is not feasible then perhaps just updating the documentation and putting the word out that every UDF should use the same variable name by convention would do it.

Attachments (0)

Change History (9)

comment:1 Changed 10 years ago by TicketCleanup

  • Version 3.3.0.0 deleted

Automatic ticket cleanup.

comment:2 Changed 10 years ago by Valik

Ehh, that's not the solution. The real problem is that it uses a global variable in the first place. The object should be passed as a parameter to the called function. Storing the object returned from ObjEvent() should be optional only if you want to unregister the event. That leads me to...

The whole system is flawed, honestly. It should be possible to register and unregister events. It should not require global variables. The return value should really be a pseudo-handle useful only to the unregister function. I'm not sure what to do about multiple events being registered to AutoIt.Error. It should probably call all registered handlers.

In short, I think the whole ObjEvent system needs rewritten to add two new functions and drastically altered behavior to be more logical. It's certainly an issue and I'll leave this open so that it's on the todo list.

comment:3 Changed 10 years ago by PsaltyDS

Well, if it's that grand a project, it implies a long time frame to do it.

In the short term, given the constraints of the current system, the UDF writers referenced (eltorro and Dale) have done what they can. Both UDFs check if a handler already exists and avoid replacing it if it does. The problem for Dale in IE.au3 is that he has a function he knows will produce a COM error event and wants to silently sink it.

For him to temporarily replace the handler, he would have to release it and put it back afterwards, but has no way to do so because there is no way to know what variable name held the reference.

If all the UDF writers were encouraged to use $oAutoItCOMError or some logical common name, then they would be able to cooperate with each other. In IE.au3, Dale would then be able to save the old handler function name, release $oAutoItCOMError, apply his own temporary handler, then restore the old one to the same object variable name.

This is not better than rewriting the whole thing to make it "right", but it could be implemented with just some verbiage in the help file and few PMs to the most common UDF writers.

I don't even know if it makes sense in this context, but my wishful-thinking idea was that the special global variable $oAutoItCOMError would be a sort of ByRef itself so that $oAutoItCOMError = 0 would release the previous handler variable, no matter what it had been named, and $oAuotItCOMError = ObjEvent("AutoIt.Error", $sOldErrorHandler) would restore the old reference too (i.e. $oXMLMyError).

comment:4 Changed 10 years ago by Valik

I will not add temporary code to solve a problem when I know it's not the right solution. Things either get fixed or they don't. I despise band-aids like what you describe.

comment:5 Changed 10 years ago by PsaltyDS

Roger, out.

comment:6 Changed 10 years ago by Jpm

  • Owner set to Gary
  • Status changed from new to assigned

comment:7 Changed 10 years ago by Jpm

  • Component changed from AutoIt to Standard UDFs

comment:8 Changed 10 years ago by Valik

  • Component changed from Standard UDFs to AutoIt
  • Owner changed from Gary to Valik
  • Summary changed from Declare a standard universal variable for the current AutoIt COM Error Handler to Better COM error handling.

I'm not sure why this was assigned to Gary and changed to the UDFs component as the root cause of the problem has absolutely nothing to do with Gary or the UDFs. I'm changing the component back to AutoIt and modifying the title.

comment:9 Changed 8 years ago by trancexx

  • Milestone set to 3.3.7.19
  • Resolution set to Fixed
  • Status changed from assigned to closed

Some aspects of COM error handler behavior have changed. Ticket is no longer valid.
Consult the documentation.

Guidelines for posting comments:

  • You cannot re-open a ticket but you may still leave a comment if you have additional information to add.
  • In-depth discussions should take place on the forum.

For more information see the full version of the ticket guidelines here.

Add Comment

Modify Ticket

Action
as closed The owner will remain Valik.
Author


E-mail address and user name can be saved in the Preferences.

 
Note: See TracTickets for help on using tickets.