jamesmontemagno / Xamarin.Forms-PullToRefreshLayout

Pull To Refresh a ScrollView or ListView in Xamarin.Forms
218 stars 49 forks source link

Fix issue #12 #75

Closed Elashi closed 4 years ago

Elashi commented 4 years ago

This PR fixes issue #12

I know I did a lot of changes but the real active change is the first commit be86aa7d4b4f99331d06f9f29c6f3174fdc7f0ee .

Description: The crash happens because new versions of Android and/or Xamarin keep sending events to disposed objects. And this is creating problems all over the place.

I solved the problem by adding a flag that indicates that the object is disposed and I checked this flag in the main event handler. I tested it on my client's project and it completely solved the problem. And I think approving this PR will cause no harm because it is a very un-harmful and innocent if statement; it merely refuses to handle events if self was disposed.

I also noticed that some code that does some clean up was commented out in the Dispose function. This did not make sense to me. The commented code looked OK to me. Commenting it out did not remove the crash for me. So to I un-commented this block of code. I hope you don't mind.

All of this was in the first aforementioned commit.

Then I added the other commits to be able to build the project in VS 2019. If you don't like them, you can drop them. They are 100% unrelated to the bug-fix.

I tried to express the reason of each commit in the commits' messages. Please let me know if you have any other concerns.

I tested this fix on my clients project and it completely fixed the crash. I honestly failed to create a test project that duplicates the problem for you but I hope that someone else can do that if it is required.

But I would like to stress again that accepting the first commit will definitely cause no harm.