- 
                Notifications
    
You must be signed in to change notification settings  - Fork 1.9k
 
[Android] Dispose check before setting properties on Button #1013
Conversation
| void UpdateBitmap() | ||
| { | ||
| if (Element == null) | ||
| if (Element == null || _isDisposed) | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
can't we do the check at a single place, in OnPropertyChanged ? and do it on the base class, so it applies to all controls ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
These methods are called all over this renderer, not just in OnPropertyChanged. The original PR that "fixed" this issue added it in just OnElementChanged. This seemed like the best way to prevent regressing this bug, and since it's a crasher, I wanted to be safe.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
| void UpdateDrawable() | ||
| { | ||
| _backgroundTracker.UpdateDrawable(); | ||
| _backgroundTracker?.UpdateDrawable(); | 
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just wondering why there is no disposed check here?
| 
           Were latest checks included into 2.3.5.255-pre5? Still crashing with "CANNOT ACCESS A DISPOSED OBJECT. OBJECT NAME: 'XAMARIN.FORMS.PLATFORM.ANDROID.FASTRENDERERS.BUTTONRENDERER'" from within IVisualElementRenderer.GetDesiredSize. Full call stack: 
  | 
    
* 2.3.5: [UWP] Fixes for usage of XF with .net native toolchain (xamarin#1024) [UWP] Make sure to update HitTestVisible when IsEnable changes (xamarin#1015) [Android] Dispose check before setting properties on Button (xamarin#1013) Add missing member variable to FormsApplicationActivity Fix NRE when background color of button set in FormsApplicationActivity (xamarin#1010) Fix border on android buttons (xamarin#941) [iOS] ListView with UnevenRows and Cell Heights will no longer be slow to load (xamarin#994) Set the Id field for Android Views created by Forms xamarin#1004 Fix build Fix possible crash on API 21+ at launch when using Holo theme and FormsApplicationActivity (xamarin#961) [Android] Remove the ". " on empty labels (Accessibility) on Fastrenderers (xamarin#915) Remove debug outputs (xamarin#1008) Add check for instance of UITableView (xamarin#885) [XamlC] fix release builds of Xaml Unit Tests Dispose check on ButtonRenderer (xamarin#975) [previewer] make sure we do not crash even if the previewer doesn't s… (xamarin#946) [XamlC] fix build Remove VisualElement finalizer (xamarin#918) [XamlC] process symbols if DebugType is set (xamarin#925)
Description of Change
Clicking a button quickly to Navigate pages can cause a crash because we weren't always checking to see if the control was disposed. Now we're checking all over the place.
Bugs Fixed
API Changes
None
Behavioral Changes
None
PR Checklist