summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorE.Z. Hart <hartez@users.noreply.github.com>2017-06-28 15:35:37 -0600
committerJason Smith <jason.smith@xamarin.com>2017-06-28 14:35:37 -0700
commit6ef847abfa3d65544c672af855c8bb24eedbd335 (patch)
tree9dc2d73f696a79b3506817bbea724480c277673c
parentc6c4b7f9be0c2d0aa100d721704bd629b4738d8f (diff)
downloadxamarin-forms-6ef847abfa3d65544c672af855c8bb24eedbd335.tar.gz
xamarin-forms-6ef847abfa3d65544c672af855c8bb24eedbd335.tar.bz2
xamarin-forms-6ef847abfa3d65544c672af855c8bb24eedbd335.zip
Add disposed check to EnsureLongClickCancellation (#1016)
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla57758.cs56
-rw-r--r--Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems1
-rw-r--r--Xamarin.Forms.Platform.Android/Renderers/ViewCellExtensions.cs5
3 files changed, 62 insertions, 0 deletions
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla57758.cs b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla57758.cs
new file mode 100644
index 00000000..f8982e68
--- /dev/null
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Bugzilla57758.cs
@@ -0,0 +1,56 @@
+using Xamarin.Forms.CustomAttributes;
+using Xamarin.Forms.Internals;
+
+#if UITEST
+using Xamarin.UITest;
+using NUnit.Framework;
+using Xamarin.Forms.Core.UITests;
+#endif
+
+namespace Xamarin.Forms.Controls.Issues
+{
+#if UITEST
+ [Category(UITestCategories.Gestures)]
+ [Category(UITestCategories.Image)]
+#endif
+
+ [Preserve(AllMembers = true)]
+ [Issue(IssueTracker.Bugzilla, 57758, "ObjectDisposedException for Xamarin.Forms.Platform.Android.FastRenderers.ImageRenderer", PlatformAffected.Android)]
+ public class Bugzilla57758 : TestContentPage
+ {
+ const string ImageId = "TestImageId";
+
+ protected override void Init()
+ {
+ var testImage = new Image { Source = "coffee.png", AutomationId = ImageId };
+
+ var layout = new StackLayout
+ {
+ Padding = new Thickness(0, 20, 0, 0),
+ Children =
+ {
+ testImage
+ }
+ };
+
+ var tapGesture = new TapGestureRecognizer
+ {
+ NumberOfTapsRequired = 1,
+ Command = new Command(() => layout.Children.Remove(testImage))
+ };
+
+ testImage.GestureRecognizers.Add(tapGesture);
+
+ Content = layout;
+ }
+
+#if UITEST
+ [Test]
+ public void RemovingImageWithGestureFromLayoutWithinGestureHandlerDoesNotCrash()
+ {
+ RunningApp.WaitForElement(ImageId);
+ RunningApp.Tap(ImageId);
+ }
+#endif
+ }
+} \ No newline at end of file
diff --git a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
index f7ae06f3..b4155f62 100644
--- a/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
+++ b/Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems
@@ -213,6 +213,7 @@
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla55912.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla57317.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla57114.cs" />
+ <Compile Include="$(MSBuildThisFileDirectory)Bugzilla57758.cs" />
<Compile Include="$(MSBuildThisFileDirectory)ButtonBackgroundColorTest.cs" />
<Compile Include="$(MSBuildThisFileDirectory)CarouselAsync.cs" />
<Compile Include="$(MSBuildThisFileDirectory)Bugzilla34561.cs" />
diff --git a/Xamarin.Forms.Platform.Android/Renderers/ViewCellExtensions.cs b/Xamarin.Forms.Platform.Android/Renderers/ViewCellExtensions.cs
index a3b34f62..278e284a 100644
--- a/Xamarin.Forms.Platform.Android/Renderers/ViewCellExtensions.cs
+++ b/Xamarin.Forms.Platform.Android/Renderers/ViewCellExtensions.cs
@@ -22,6 +22,11 @@ namespace Xamarin.Forms.Platform.Android
public static void EnsureLongClickCancellation(this AView view, MotionEvent motionEvent, bool handled, VisualElement element)
{
+ if (view.IsDisposed())
+ {
+ return;
+ }
+
if (motionEvent.Action == MotionEventActions.Up && handled && view.LongClickable && element.IsInViewCell())
{
// In order for long presses/clicks (for opening context menus) to work in a ViewCell