Bug 20452 - After call getter NavigationController of UIViewController class, my ViewController can not dispose
Summary: After call getter NavigationController of UIViewController class, my ViewCont...
Status: RESOLVED FEATURE
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: master
Hardware: PC Mac OS
: --- normal
Target Milestone: Untriaged
Assignee: Bugzilla
URL:
Depends on:
Blocks:
 
Reported: 2014-06-07 01:18 UTC by thong doan
Modified: 2014-06-08 12:42 UTC (History)
2 users (show)

Tags:
Is this bug a regression?: ---
Last known good build:

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.


Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:
Status:
RESOLVED FEATURE

Description thong doan 2014-06-07 01:18:16 UTC
public override UINavigationController NavigationController {
			get {
				UIApplication.EnsureUIThread ();
				UINavigationController nSObject;
				if (this.IsDirectBinding) {
					nSObject = Runtime.GetNSObject<UINavigationController> (Messaging.IntPtr_objc_msgSend (base.Handle, Selector.GetHandle ("navigationController")));
				}
				else {
					nSObject = Runtime.GetNSObject<UINavigationController> (Messaging.IntPtr_objc_msgSendSuper (base.SuperHandle, Selector.GetHandle ("navigationController")));
				}
				/*
				 * Origin  Source
				if (!NSObject.IsNewRefcountEnabled ()) {
					this.__mt_NavigationController_var = nSObject;
				}
				*/
				return nSObject;
			}
		}
I enter into decomplie code and override this getter remove "this.__mt_NavigationController_var = nSObject" to fix it
Comment 1 Sebastien Pouliot 2014-06-08 11:14:36 UTC
That's the wrong (partial) fix as it will never keep the reference, even when it's needed (i.e. any callback from native to managed could crash).

What you need is to enable the "New RecCount extensions" in your project. That will remove the backing field (not just comment it's use) *and* ensure that the reference is kept around as long as the native side requires it.

See the Xamarin.iOS 7.2.1 release notes [1] for mre details.

[1] http://developer.xamarin.com/releases/ios/xamarin.ios_7/xamarin.ios_7.2/#1
Comment 2 thong doan 2014-06-08 12:42:49 UTC
I have just read the release notes that you said, i will try New Reference Counting System.
Thank for your reply.