# HG changeset patch # User Chris Cannam # Date 1409740918 -3600 # Node ID f84f1828420b255452bb0de000be8aa915130450 # Parent 0f5961c1bb6c7540eb466f5c37bbf3236e7fe166 Clarify some sneaky logic diff -r 0f5961c1bb6c -r f84f1828420b layer/RegionLayer.cpp --- a/layer/RegionLayer.cpp Wed Sep 03 11:33:57 2014 +0100 +++ b/layer/RegionLayer.cpp Wed Sep 03 11:41:58 2014 +0100 @@ -47,6 +47,10 @@ SingleColourLayer(), m_model(0), m_editing(false), + m_dragPointX(0), + m_dragPointY(0), + m_dragStartX(0), + m_dragStartY(0), m_originalPoint(0, 0.0, 0, tr("New Region")), m_editingPoint(0, 0.0, 0, tr("New Region")), m_editingCommand(0), @@ -564,13 +568,21 @@ i = close.begin(); // Scan through the close points first, then the more distant ones - // if no suitable close one is found + // if no suitable close one is found. So the while-termination + // condition here can only happen once i has passed through the + // whole of the close container and then the whole of the separate + // points container. The two iterators are totally distinct, but + // have the same type so we cheekily use the same variable and a + // single loop for both. while (i != points.end()) { - if (i == close.end()) { - i = points.begin(); - distant = true; + if (!distant) { + if (i == close.end()) { + // switch from the close container to the points container + i = points.begin(); + distant = true; + } } if (snap == SnapRight) {