Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2014-10-10 13:45:47 +0400
committerTamito Kajiyama <rd6t-kjym@asahi-net.or.jp>2014-10-10 13:57:35 +0400
commit5fdbb793ff40a8c67200f147104fee6d3867afe1 (patch)
tree4597dff06523db5f32b52c30c4d96179a1bdc61d /source/blender/freestyle/intern/python/Iterator
parent642c8243e7a5425de949892ab7a43a3e2077e122 (diff)
Freestyle: Fix for StrokeVertexIterator.__next__() ignoring the first and only element.
A StrokeVertexIterator ignores the first element when it is the only element. Such an iterator can be created by the .incremented() method from an iterator over two stroke vertices. This problem is a regression from 2.71. The present fix is appropriate to backport if Blender 2.72a is planned. Problem report by Kazuhiro Murakawa through personal communications, thanks!
Diffstat (limited to 'source/blender/freestyle/intern/python/Iterator')
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp12
-rw-r--r--source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp22
2 files changed, 23 insertions, 11 deletions
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
index c972db1e680..7419f0ed127 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_Interface0DIterator.cpp
@@ -120,14 +120,20 @@ static PyObject *Interface0DIterator_iternext(BPy_Interface0DIterator *self)
self->if0D_it->decrement();
}
else {
- if (self->if0D_it->atLast() || self->if0D_it->isEnd()) {
+ if (self->if0D_it->isEnd()) {
PyErr_SetNone(PyExc_StopIteration);
return NULL;
}
- if (self->at_start)
+ else if (self->at_start) {
self->at_start = false;
- else
+ }
+ else if (self->if0D_it->atLast()) {
+ PyErr_SetNone(PyExc_StopIteration);
+ return NULL;
+ }
+ else {
self->if0D_it->increment();
+ }
}
Interface0D *if0D = self->if0D_it->operator->();
return Any_BPy_Interface0D_from_Interface0D(*if0D);
diff --git a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp
index 18d1b37eb3b..275bfe99714 100644
--- a/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp
+++ b/source/blender/freestyle/intern/python/Iterator/BPy_StrokeVertexIterator.cpp
@@ -115,19 +115,25 @@ static PyObject *StrokeVertexIterator_iternext(BPy_StrokeVertexIterator *self)
self->sv_it->decrement();
}
else {
- /* if sv_it.isEnd() is true, the iterator can't be incremented. if sv_it.isLast() is true,
- * the iterator is currently pointing to the final valid argument. Incrementing it further would
- * give a python object that can't be dereferenced. */
- if (self->sv_it->atLast() || self->sv_it->isEnd()) {
+ /* If sv_it.isEnd() is true, the iterator can't be incremented. */
+ if (self->sv_it->isEnd()) {
PyErr_SetNone(PyExc_StopIteration);
return NULL;
}
- /* if at the start of the iterator, only return the object
- * and don't increment, to keep for-loops in sync */
- if (self->at_start)
+ /* If at the start of the iterator, only return the object
+ * and don't increment, to keep for-loops in sync */
+ else if (self->at_start) {
self->at_start = false;
- else
+ }
+ /* If sv_it.atLast() is true, the iterator is currently pointing to the final valid element.
+ * Incrementing it further would lead to a state that the iterator can't be dereferenced. */
+ else if (self->sv_it->atLast()) {
+ PyErr_SetNone(PyExc_StopIteration);
+ return NULL;
+ }
+ else {
self->sv_it->increment();
+ }
}
StrokeVertex *sv = self->sv_it->operator->();
return BPy_StrokeVertex_from_StrokeVertex(*sv);