@@ -163,6 +163,7 @@ class PathNanRemover : protected EmbeddedQueue<4>
163
163
VertexSource *m_source;
164
164
bool m_remove_nans;
165
165
bool m_has_curves;
166
+ bool valid_segment_exists;
166
167
167
168
public:
168
169
/* has_curves should be true if the path contains bezier curve
@@ -172,7 +173,9 @@ class PathNanRemover : protected EmbeddedQueue<4>
172
173
PathNanRemover (VertexSource &source, bool remove_nans, bool has_curves)
173
174
: m_source(&source), m_remove_nans(remove_nans), m_has_curves(has_curves)
174
175
{
175
- // empty
176
+ // ignore all close/end_poly commands until after the first valid
177
+ // (nan-free) command is encountered
178
+ valid_segment_exists = false ;
176
179
}
177
180
178
181
inline void rewind (unsigned path_id)
@@ -202,8 +205,11 @@ class PathNanRemover : protected EmbeddedQueue<4>
202
205
are found along the way, the queue is emptied, and
203
206
the next curve segment is handled. */
204
207
code = m_source->vertex (x, y);
205
- if (code == agg::path_cmd_stop ||
206
- code == (agg::path_cmd_end_poly | agg::path_flags_close)) {
208
+ if (code == agg::path_cmd_stop) {
209
+ return code;
210
+ }
211
+ if (code == (agg::path_cmd_end_poly | agg::path_flags_close)
212
+ && valid_segment_exists) {
207
213
return code;
208
214
}
209
215
@@ -224,6 +230,7 @@ class PathNanRemover : protected EmbeddedQueue<4>
224
230
}
225
231
226
232
if (!has_nan) {
233
+ valid_segment_exists = true ;
227
234
break ;
228
235
}
229
236
0 commit comments