Vidar Hasfjord - 2010-03-19

Possible solutions to aliasing issues

by [[User:Vattila|Vattila]] 15:47, 19 March 2010 (UTC)

A solution to the first aliasing issue (1) for the BI_NOTHUNK option requires TWindow to not only store a pointer to the original window procedure, but also a pointer to the window object that owns it, if any. The object pointer is needed to update the look-up table. This is unlike the thunking solution, where the window object pointer is part of the window procedure itself.

A solution to the second issue (2) is harder. It requires a notification protocol between all the aliases and the owner (if any) of an interface element, so that an alias is notified of the death of the original window object whose window procedure it stores, and is given its original window procedure as a replacement, i.e. the window procedure that was active before the dying object subclassed the element. Using the example in the article, A notifies B about its death and passes on the original window procedure that was active when A subclassed the element. When B finally dies it restores this windows procedure. The element is thus left in the state it was before A and B subclassed it.

There is currently no ongoing effort to fix these issues.

Possible solutions to reattachment issues

by [[User:Vattila|Vattila]] 15:47, 19 March 2010 (UTC)

Clean-up must be done while the handle is still valid. Otherwise we have no access to the interface element, which leaves us unable to restore the original window procedure. The BI_NOTHUNK option also needs to remove the window object from the look-up table and replace it by the entry for the original object, if any.

A possible approach to control proper clean-up and reattachment is to handle it in SetHandle. The idea is that clean-up before reattachment can then be ensured by enforcing the rule that all handle assignments are done by calling SetHandle, and that a SetHandle (0) is executed wherever detachment and clean-up is required (mainly in the destructor). The poor encapsulation and the myriad of possible execution paths through the TWindow code makes this tricky to ensure, so this solution may entail some refactoring of the code.

Also, unless OWLNext is compiled with the OWL_STRICT_DATA option, the handle is unfortunately public, so client code may circumvent proper management of clean-up and reattachment by modifying the handle directly. Hence a robust solution requires that OWL_STRICT_DATA becomes the default and only disabled for compatibility modes.