Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Exception on Dispose #10

Closed
daveclarke opened this issue Nov 13, 2017 · 5 comments
Closed

Exception on Dispose #10

daveclarke opened this issue Nov 13, 2017 · 5 comments

Comments

@daveclarke
Copy link

I have a button defined in XAML as:

<buttoncircle:CircleButton Grid.Row="8" Grid.Column="1" x:Name="infoButton" Icon="ic_info" TextColor="White" FontSize="24" HeightRequest="24" WidthRequest="24" BorderThickness="1" BackgroundColor="#0076fa" VerticalOptions="Center" HorizontalOptions="Center" Command="{Binding InfoCommand}" />

It displays perfectly and is used to display some information text on a new page. But if I cancel from the page even without tapping the button I get a null reference exception that appears to be an issue triggered by trying to Dispose the button.

at ButtonCircle.FormsPlugin.iOS.ButtonCircleRenderer.OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs1[TElement] e) [0x00022] in <a4abc774e1e04cf88321114ac113a4d8>:0 at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].SetElement (TElement element) [0x00118] in :0
at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].Dispose (System.Boolean disposing) [0x0008c] in <eb211aa32ac8429489411f4d642db9c2>:0 at Xamarin.Forms.Platform.iOS.ViewRenderer2[TView,TNativeView].Dispose (System.Boolean disposing) [0x00000] in :0
at Xamarin.Forms.Platform.iOS.ButtonRenderer.Dispose (System.Boolean disposing) [0x00036] in :0
at Foundation.NSObject.Dispose () [0x00000] in /Users/builder/data/lanes/5520/51128b8c/source/xamarin-macios/src/Foundation/NSObject2.cs:133
at Xamarin.Forms.Platform.iOS.Platform.DisposeModelAndChildrenRenderers (Xamarin.Forms.Element view) [0x00038] in :0
at Xamarin.Forms.Platform.iOS.Platform+d__23.MoveNext () [0x0015f] in :0
--- End of stack trace from previous location where exception was thrown ---

Is there something I'm missing here?

@wilsonvargas
Copy link
Owner

how do you cancel button? can you show me your code please?

@daveclarke
Copy link
Author

daveclarke commented Nov 13, 2017

I'm not sure I understand the question. I declare the button in xaml. I'm using FreshMvvm framework for the app so when I want to navigate back to the previous page I use:

 await CoreMethods.PopPageModel(data: true, modal: true, animate: true);

I've just checked FreshMvvm source and PopPageModel resolves to

public virtual Task PopPage (bool modal = false, bool animate = true)
    {
        if (modal)
            return Navigation.PopModalAsync (animate);
        return Navigation.PopAsync (animate);
    }

And Navigation.PopModalAsync() is a Xamarin.Forms method. Not sure if that helps.

@daveclarke
Copy link
Author

https://bugzilla.xamarin.com/show_bug.cgi?id=21457 is an old reference but may be relevant?

@extraPaul
Copy link

I'm getting the same issue. I have a page that has multiple CircleButtons, and when I navigate back to the home page I get a null reference exception. I use Navigation.PopAsync() to go back to the home page. Here is part of the stack trace:

Object reference not set to an instance of an object (System.NullReferenceException)
at ButtonCircle.FormsPlugin.iOS.ButtonCircleRenderer.OnElementChanged (Xamarin.Forms.Platform.iOS.ElementChangedEventArgs1[TElement] e) [0x00022] in <a4abc774e1e04cf88321114ac113a4d8>:0 at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].SetElement (TElement element) [0x00118] in :0
at Xamarin.Forms.Platform.iOS.VisualElementRenderer1[TElement].Dispose (System.Boolean disposing) [0x0008c] in <eb211aa32ac8429489411f4d642db9c2>:0 at Xamarin.Forms.Platform.iOS.ViewRenderer2[TView,TNativeView].Dispose (System.Boolean disposing) [0x00000] in :0
at Xamarin.Forms.Platform.iOS.ButtonRenderer.Dispose (System.Boolean disposing) [0x00036] in D:\agent_work\1\s\Xamarin.Forms.Platform.iOS\Renderers\ButtonRenderer.cs:48
at Foundation.NSObject.Dispose ()

As mentioned earlier, it seems like the exception is thrown as the button is being disposed.

wilsonvargas added a commit that referenced this issue Nov 20, 2017
Exception on Dispose #10
And
Multi Line Labels in Buttons #11
@wilsonvargas
Copy link
Owner

Check latest version (1.2.52). I tested this version on an IPhone with iOS 11, Samsung Galaxy S8 with Android 7.1 and in my computer with Windows 10, it's work fine.

Please tell me if you have a issue again.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants