Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings
This repository was archived by the owner on May 1, 2024. It is now read-only.
/Xamarin.FormsPublic archive

Commitdad72d3

Browse files
Fixed issue creating Paths with segments without points on iOS (#13161)
Co-authored-by: Gerald Versluis <gerald.versluis@microsoft.com>
1 parent430754b commitdad72d3

File tree

3 files changed

+130
-3
lines changed

3 files changed

+130
-3
lines changed
Lines changed: 126 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,126 @@
1+
usingXamarin.Forms.CustomAttributes;
2+
usingXamarin.Forms.Internals;
3+
usingXamarin.Forms.Shapes;
4+
5+
#ifUITEST
6+
usingXamarin.UITest;
7+
usingNUnit.Framework;
8+
usingXamarin.Forms.Core.UITests;
9+
#endif
10+
11+
namespaceXamarin.Forms.Controls.Issues
12+
{
13+
[Preserve(AllMembers=true)]
14+
[Issue(IssueTracker.Github,13159,"[Bug] +Fix. Path.Data crashing when geometry has a PolyLineSegment with 0 point",
15+
PlatformAffected.iOS)]
16+
#ifUITEST
17+
[Category(UITestCategories.Shape)]
18+
#endif
19+
publicclassIssue13159:TestContentPage
20+
{
21+
conststringTestReady="TestReadyId";
22+
23+
publicIssue13159()
24+
{
25+
26+
}
27+
28+
protectedoverridevoidInit()
29+
{
30+
varlayout=newStackLayout();
31+
32+
varinstructions=newLabel
33+
{
34+
AutomationId=TestReady,
35+
Padding=12,
36+
BackgroundColor=Color.Black,
37+
TextColor=Color.White,
38+
Text="Without exceptions, the test has passed."
39+
};
40+
41+
layout.Children.Add(instructions);
42+
layout.Children.Add(CreateNoPointsPolyLineSegmentPath());
43+
layout.Children.Add(CreateNoPointsPolyBezierSegmentPath());
44+
layout.Children.Add(CreateNoPointsPolyQuadraticBezierSegmentPath());
45+
layout.Children.Add(CreateNoPointsArcSegmentPath());
46+
47+
Content=layout;
48+
}
49+
50+
PathCreateNoPointsPolyLineSegmentPath()
51+
{
52+
varpath=newPath();
53+
54+
PathFigurepathFigure=newPathFigure();
55+
56+
pathFigure.Segments.Add(newPolyLineSegment());
57+
58+
PathGeometrygeometry=newPathGeometry();
59+
60+
geometry.Figures.Add(pathFigure);
61+
62+
path.Data=geometry;
63+
64+
returnpath;
65+
}
66+
67+
PathCreateNoPointsPolyBezierSegmentPath()
68+
{
69+
varpath=newPath();
70+
71+
PathFigurepathFigure=newPathFigure();
72+
73+
pathFigure.Segments.Add(newPolyBezierSegment());
74+
75+
PathGeometrygeometry=newPathGeometry();
76+
77+
geometry.Figures.Add(pathFigure);
78+
79+
path.Data=geometry;
80+
81+
returnpath;
82+
}
83+
84+
PathCreateNoPointsPolyQuadraticBezierSegmentPath()
85+
{
86+
varpath=newPath();
87+
88+
PathFigurepathFigure=newPathFigure();
89+
90+
pathFigure.Segments.Add(newPolyQuadraticBezierSegment());
91+
92+
PathGeometrygeometry=newPathGeometry();
93+
94+
geometry.Figures.Add(pathFigure);
95+
96+
path.Data=geometry;
97+
98+
returnpath;
99+
}
100+
101+
PathCreateNoPointsArcSegmentPath()
102+
{
103+
varpath=newPath();
104+
105+
PathFigurepathFigure=newPathFigure();
106+
107+
pathFigure.Segments.Add(newArcSegment());
108+
109+
PathGeometrygeometry=newPathGeometry();
110+
111+
geometry.Figures.Add(pathFigure);
112+
113+
path.Data=geometry;
114+
115+
returnpath;
116+
}
117+
118+
#ifUITEST&&__IOS__
119+
[Test]
120+
publicvoidIssue13159NoPointsPathTest()
121+
{
122+
RunningApp.WaitForElement(TestReady);
123+
}
124+
#endif
125+
}
126+
}

‎Xamarin.Forms.Controls.Issues/Xamarin.Forms.Controls.Issues.Shared/Xamarin.Forms.Controls.Issues.Shared.projitems‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1794,6 +1794,7 @@
17941794
<CompileInclude="$(MSBuildThisFileDirectory)Issue8833.xaml.cs" />
17951795
<CompileInclude="$(MSBuildThisFileDirectory)Issue10086.xaml.cs" />
17961796
<CompileInclude="$(MSBuildThisFileDirectory)Issue13136.xaml.cs" />
1797+
<CompileInclude="$(MSBuildThisFileDirectory)Issue13159.cs" />
17971798
<CompileInclude="$(MSBuildThisFileDirectory)Issue11980.cs" />
17981799
<CompileInclude="$(MSBuildThisFileDirectory)Issue13173.xaml.cs" />
17991800
<CompileInclude="$(MSBuildThisFileDirectory)Issue8282.xaml.cs" />

‎Xamarin.Forms.Platform.iOS/Extensions/GeometryExtensions.cs‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ public static PathData ToCGPath(this Geometry geometry, Transform renderTransfor
9090
for(inti=0;i<points.Count;i++)
9191
pathData.Data.AddLineToPoint(transform,points[i].ToPointF());
9292

93-
lastPoint=points[points.Count-1];
93+
lastPoint=points.Count>0?points[points.Count-1]:Point.Zero;
9494
}
9595
// BezierSegment
9696
elseif(pathSegmentisBezierSegment)
@@ -123,7 +123,7 @@ public static PathData ToCGPath(this Geometry geometry, Transform renderTransfor
123123
}
124124
}
125125

126-
lastPoint=points[points.Count-1];
126+
lastPoint=points.Count>0?points[points.Count-1]:Point.Zero;
127127
}
128128
// QuadraticBezierSegment
129129
elseif(pathSegmentisQuadraticBezierSegment)
@@ -158,7 +158,7 @@ public static PathData ToCGPath(this Geometry geometry, Transform renderTransfor
158158
}
159159
}
160160

161-
lastPoint=points[points.Count-1];
161+
lastPoint=points.Count>0?points[points.Count-1]:Point.Zero;
162162
}
163163
// ArcSegment
164164
elseif(pathSegmentisArcSegment)

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp