The following sequence will trigger an assert during the second QPainterPath::moveTo() call:
The second moveTo() triggers this assert:
This is because the call to clear() has cleared all the path elements, including the initial MoveTo, but data still exists so it's not re-initialized by the previous ensureData() call.
Maybe QPainterPath::ensureData() shall insert a first null MoveTo element when the d-pointer exists but has empty data (which is the state it's in after a clear).
Or QPainterPath::clear() shall ensure that the path data contains at least a null MoveTo if it's not null.