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;
|
||||
|
||||
if(!iterator || !path)
|
||||
if(!iterator)
|
||||
return InvalidParameter;
|
||||
|
||||
size = path->pathdata.Count;
|
||||
|
||||
*iterator = GdipAlloc(sizeof(GpPathIterator));
|
||||
if(!*iterator) return OutOfMemory;
|
||||
|
||||
(*iterator)->pathdata.Types = GdipAlloc(size);
|
||||
(*iterator)->pathdata.Points = GdipAlloc(size * sizeof(PointF));
|
||||
if(path){
|
||||
size = path->pathdata.Count;
|
||||
|
||||
memcpy((*iterator)->pathdata.Types, path->pathdata.Types, size);
|
||||
memcpy((*iterator)->pathdata.Points, path->pathdata.Points,
|
||||
size * sizeof(PointF));
|
||||
(*iterator)->pathdata.Count = size;
|
||||
(*iterator)->pathdata.Types = GdipAlloc(size);
|
||||
(*iterator)->pathdata.Points = GdipAlloc(size * sizeof(PointF));
|
||||
|
||||
(*iterator)->subpath_pos = 0;
|
||||
(*iterator)->marker_pos = 0;
|
||||
memcpy((*iterator)->pathdata.Types, path->pathdata.Types, size);
|
||||
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;
|
||||
|
||||
return Ok;
|
||||
|
@ -156,6 +162,10 @@ GpStatus WINGDIPAPI GdipPathIterNextSubpath(GpPathIterator* iterator,
|
|||
|
||||
count = iterator->pathdata.Count;
|
||||
|
||||
/* iterator created with NULL path */
|
||||
if(count == 0)
|
||||
return Ok;
|
||||
|
||||
if(iterator->subpath_pos == count){
|
||||
*startIndex = *endIndex = *resultCount = 0;
|
||||
*isClosed = 1;
|
||||
|
|
|
@ -37,7 +37,7 @@ static void test_constructor_destructor(void)
|
|||
stat = GdipCreatePathIter(NULL, NULL);
|
||||
expect(InvalidParameter, stat);
|
||||
stat = GdipCreatePathIter(&iter, NULL);
|
||||
expect(InvalidParameter, stat);
|
||||
expect(Ok, stat);
|
||||
stat = GdipCreatePathIter(NULL, path);
|
||||
expect(InvalidParameter, stat);
|
||||
stat = GdipDeletePathIter(NULL);
|
||||
|
|
Loading…
Reference in New Issue