| 217 | } |
| 218 | |
| 219 | void BreakpointModel::removeBreakpointMarks(KTextEditor::Document& document) |
| 220 | { |
| 221 | const auto& marks = document.marks(); |
| 222 | if (marks.empty()) { |
| 223 | return; |
| 224 | } |
| 225 | |
| 226 | const auto guard = markChangeGuard(); |
| 227 | |
| 228 | // A call to KTextEditor::Document::removeMark() usually erases an element from the document's marks() container. |
| 229 | // Erasing an element can invalidate iterators and thus requires iterating over a copy. |
| 230 | // Iterating over a copy of the marks() container would almost certainly detach it and thus end implicit sharing. |
| 231 | // Iterate over a local container of keys both for code simplicity (no need for QHash::key_value_iterator) |
| 232 | // and performance (the QList is smaller than the QHash and is ideal for the loop below). |
| 233 | const auto markLines = marks.keys(); |
| 234 | for (const int line : markLines) { |
| 235 | document.removeMark(line, AllBreakpointMarks); |
| 236 | } |
| 237 | } |
| 238 | |
| 239 | void BreakpointModel::aboutToReload() |
| 240 | { |