gdiplus: Fix GdipCreatePathIter to handle NULL as path. Fix tests.
This commit is contained in:
parent
6ef6f7167d
commit
dcfbe58ef7
|
@ -31,24 +31,30 @@ GpStatus WINGDIPAPI GdipCreatePathIter(GpPathIterator **iterator, GpPath* path)
|
||||||
{
|
{
|
||||||
INT size;
|
INT size;
|
||||||
|
|
||||||
if(!iterator || !path)
|
if(!iterator)
|
||||||
return InvalidParameter;
|
return InvalidParameter;
|
||||||
|
|
||||||
size = path->pathdata.Count;
|
|
||||||
|
|
||||||
*iterator = GdipAlloc(sizeof(GpPathIterator));
|
*iterator = GdipAlloc(sizeof(GpPathIterator));
|
||||||
if(!*iterator) return OutOfMemory;
|
if(!*iterator) return OutOfMemory;
|
||||||
|
|
||||||
(*iterator)->pathdata.Types = GdipAlloc(size);
|
if(path){
|
||||||
(*iterator)->pathdata.Points = GdipAlloc(size * sizeof(PointF));
|
size = path->pathdata.Count;
|
||||||
|
|
||||||
memcpy((*iterator)->pathdata.Types, path->pathdata.Types, size);
|
(*iterator)->pathdata.Types = GdipAlloc(size);
|
||||||
memcpy((*iterator)->pathdata.Points, path->pathdata.Points,
|
(*iterator)->pathdata.Points = GdipAlloc(size * sizeof(PointF));
|
||||||
size * sizeof(PointF));
|
|
||||||
(*iterator)->pathdata.Count = size;
|
|
||||||
|
|
||||||
(*iterator)->subpath_pos = 0;
|
memcpy((*iterator)->pathdata.Types, path->pathdata.Types, size);
|
||||||
(*iterator)->marker_pos = 0;
|
memcpy((*iterator)->pathdata.Points, path->pathdata.Points,size * sizeof(PointF));
|
||||||
|
(*iterator)->pathdata.Count = size;
|
||||||
|
}
|
||||||
|
else{
|
||||||
|
(*iterator)->pathdata.Types = NULL;
|
||||||
|
(*iterator)->pathdata.Points = NULL;
|
||||||
|
(*iterator)->pathdata.Count = 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
(*iterator)->subpath_pos = 0;
|
||||||
|
(*iterator)->marker_pos = 0;
|
||||||
(*iterator)->pathtype_pos = 0;
|
(*iterator)->pathtype_pos = 0;
|
||||||
|
|
||||||
return Ok;
|
return Ok;
|
||||||
|
@ -156,6 +162,10 @@ GpStatus WINGDIPAPI GdipPathIterNextSubpath(GpPathIterator* iterator,
|
||||||
|
|
||||||
count = iterator->pathdata.Count;
|
count = iterator->pathdata.Count;
|
||||||
|
|
||||||
|
/* iterator created with NULL path */
|
||||||
|
if(count == 0)
|
||||||
|
return Ok;
|
||||||
|
|
||||||
if(iterator->subpath_pos == count){
|
if(iterator->subpath_pos == count){
|
||||||
*startIndex = *endIndex = *resultCount = 0;
|
*startIndex = *endIndex = *resultCount = 0;
|
||||||
*isClosed = 1;
|
*isClosed = 1;
|
||||||
|
|
|
@ -37,7 +37,7 @@ static void test_constructor_destructor(void)
|
||||||
stat = GdipCreatePathIter(NULL, NULL);
|
stat = GdipCreatePathIter(NULL, NULL);
|
||||||
expect(InvalidParameter, stat);
|
expect(InvalidParameter, stat);
|
||||||
stat = GdipCreatePathIter(&iter, NULL);
|
stat = GdipCreatePathIter(&iter, NULL);
|
||||||
expect(InvalidParameter, stat);
|
expect(Ok, stat);
|
||||||
stat = GdipCreatePathIter(NULL, path);
|
stat = GdipCreatePathIter(NULL, path);
|
||||||
expect(InvalidParameter, stat);
|
expect(InvalidParameter, stat);
|
||||||
stat = GdipDeletePathIter(NULL);
|
stat = GdipDeletePathIter(NULL);
|
||||||
|
|
Loading…
Reference in New Issue