Bug 8 - UIAlertView: we should keep an implicit reference until disposed
Summary: UIAlertView: we should keep an implicit reference until disposed
Status: RESOLVED FIXED
Alias: None
Product: iOS
Classification: Xamarin
Component: Xamarin.iOS.dll ()
Version: 1.0
Hardware: PC Mac OS
: --- enhancement
Target Milestone: Untriaged
Assignee: Miguel de Icaza [MSFT]
URL:
Depends on:
Blocks:
 
Reported: 2011-07-16 22:42 UTC by Miguel de Icaza [MSFT]
Modified: 2011-08-05 11:50 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 FIXED

Description Miguel de Icaza [MSFT] 2011-07-16 22:42:41 UTC
We should keep an implicit reference to UIAlertViews until they are dismissed, without requring the user to keep a reference themselves.   This is a major source of bugs for our users.

To fix this, what we need to do is:

* Flag the Show method as internal
* Flag the Delegate [Wrap] method as internal.
* Expose a new Delegate method that will always inject a proxy in between.
* The proxy delegates every method call to the original class.

The only difference is that when the public Show is created, we keep track of the instance in a static table.    And when Dismissed is invoked on the proxy, we remove it.
Comment 1 Chris Toshok 2011-08-05 02:24:21 UTC
Hm, do you have an example of the code we *want* to work but isn't working?

I put this inside the default monodevelop template:

	public override bool FinishedLaunching (UIApplication app, NSDictionary options)
	{
		window.MakeKeyAndVisible ();
		UIAlertView alert = new UIAlertView ("Alert!", "something bad happened!", null, "cancel", "uh huh");			
		alert.Show ();
		return true;
	}

and it seems to work.. just because the GC hasn't run?
Comment 2 Miguel de Icaza [MSFT] 2011-08-05 11:50:34 UTC
My bad, this is now taken care of from the last MonoTouch Novell release.   It is no longer an issue.  Just my bad memory.

Geoff introduced a system to keep around references until a delegate method was invoked, the KeepRefUntil parameter in BaseType