IsmAvatar / LateralGM

A free Game Maker source file editor
http://lateralgm.org/
Other
95 stars 25 forks source link

Property Link Factory Context #551

Closed RobertBColton closed 3 years ago

RobertBColton commented 3 years ago

This fixes the concurrency exceptions reintroduced by c85f9581f9266e74bb52c37218e353430d2d0191 for property links. The problem was our weak references to the secondary property link factories were being GC'd too early sometimes, making it impossible for us to clean up the old links. My solution is to just save a reference to the secondary property link factories and use it to update the links when the current item changes in Master-Detail views.

This is actually less memory and cleaner code because we don't need to save the individual links. Since the factories keep a list of all links to dispose of them, we already have what we need to bind them to a different map. This is also faster because now we avoid unnecessary object creation by reusing the existing links instead of creating new ones. This is pretty much similar to the .NET equivalents like BindingOperations, BindingContext, and BindingManagerBase.