This repository has been archived by the owner on May 1, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[iOS] Fixed crash updating ToolbarItem icon (already disposed) (#14749)
* Add repro sample * Fixed the issue * Fix build error Co-authored-by: Gerald Versluis <[email protected]>
- Loading branch information
1 parent
d7f8e42
commit 1b0d8f2
Showing
4 changed files
with
106 additions
and
9 deletions.
There are no files selected for viewing
15 changes: 15 additions & 0 deletions
15
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue6387.xaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
<?xml version="1.0" encoding="utf-8" ?> | ||
<controls:TestContentPage | ||
xmlns:controls="clr-namespace:Xamarin.Forms.Controls" | ||
xmlns="http://xamarin.com/schemas/2014/forms" | ||
xmlns:x="http://schemas.microsoft.com/winfx/2009/xaml" | ||
x:Class="Xamarin.Forms.Controls.Issues.Issue6387" | ||
Title="Issue 6387"> | ||
<ContentPage.Content> | ||
<StackLayout> | ||
<Label | ||
Padding="12" | ||
Text="Tap the ToolBarItem with an Icon. Without exceptions, the test has passed." /> | ||
</StackLayout> | ||
</ContentPage.Content> | ||
</controls:TestContentPage> |
61 changes: 61 additions & 0 deletions
61
Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Issue6387.xaml.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,61 @@ | ||
using System; | ||
using System.Collections.Generic; | ||
using System.Diagnostics; | ||
using Xamarin.Forms.CustomAttributes; | ||
using Xamarin.Forms.Internals; | ||
using System.Reflection; | ||
|
||
#if UITEST | ||
using Xamarin.UITest; | ||
using NUnit.Framework; | ||
using Xamarin.Forms.Core.UITests; | ||
#endif | ||
|
||
namespace Xamarin.Forms.Controls.Issues | ||
{ | ||
#if UITEST | ||
[Category(UITestCategories.ToolbarItem)] | ||
#endif | ||
[Preserve(AllMembers = true)] | ||
[Issue(IssueTracker.Github, 6387, | ||
"[Bug] [iOS] Crash When the First Toolbar Item Has an Icon and a Second Item Gets Added", | ||
PlatformAffected.iOS)] | ||
public partial class Issue6387 : TestContentPage | ||
{ | ||
#if APP | ||
readonly ToolbarItem _item0; | ||
readonly ToolbarItem _item1; | ||
#endif | ||
public Issue6387() | ||
{ | ||
#if APP | ||
InitializeComponent(); | ||
|
||
_item0 = new ToolbarItem("Item 0", null, ClearAndAddToolbarItems) | ||
{ | ||
IconImageSource = ImageSource.FromResource("Xamarin.Forms.Controls.GalleryPages.crimson.jpg", typeof(Issue6387).GetTypeInfo().Assembly) | ||
}; | ||
_item1 = new ToolbarItem("Item 1", null, ClearAndAddToolbarItems) | ||
{ | ||
// It doesn't matter if this item has an image or not. | ||
}; | ||
|
||
ClearAndAddToolbarItems(); | ||
#endif | ||
} | ||
|
||
protected override void Init() | ||
{ | ||
|
||
} | ||
#if APP | ||
void ClearAndAddToolbarItems() | ||
{ | ||
ToolbarItems.Clear(); | ||
|
||
ToolbarItems.Add(_item0); | ||
ToolbarItems.Add(_item1); | ||
} | ||
#endif | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters