| 184 | } |
| 185 | |
| 186 | void BreakpointModel::documentUrlChanged(KDevelop::IDocument* document, const QUrl& previousUrl) |
| 187 | { |
| 188 | Q_D(BreakpointModel); |
| 189 | |
| 190 | // Ignore non-text documents. |
| 191 | if (!document->textDocument()) { |
| 192 | return; |
| 193 | } |
| 194 | |
| 195 | // We rely on previousUrl being an IDocument::url(), which is unique and never empty. |
| 196 | // An empty previousUrl is unacceptable, because a breakpoint's empty URL |
| 197 | // value means "none" and must not be replaced in the loop below. |
| 198 | Q_ASSERT(!previousUrl.isEmpty()); |
| 199 | |
| 200 | std::vector<Breakpoint*> updatedBreakpoints; |
| 201 | const auto destinationUrl = document->url(); |
| 202 | for (auto* const breakpoint : std::as_const(d->breakpoints)) { |
| 203 | // Ignore unsuitable breakpoints. |
| 204 | if (breakpoint->kind() != Breakpoint::CodeBreakpoint || breakpoint->url() != previousUrl) { |
| 205 | continue; |
| 206 | } |
| 207 | // Update the breakpoint to use the (renamed to) destinationUrl. |
| 208 | breakpoint->assignUrl(destinationUrl); |
| 209 | updatedBreakpoints.push_back(breakpoint); |
| 210 | } |
| 211 | |
| 212 | // The loop above silently reassigns URLs to restore consistency between the Breakpoint URLs and moving cursors. |
| 213 | // Notify the world about the URL changes in this separate loop to avoid possible inconsistency issues. |
| 214 | for (auto* const breakpoint : updatedBreakpoints) { |
| 215 | reportChange(breakpoint, Breakpoint::LocationColumn); |
| 216 | } |
| 217 | } |
| 218 | |
| 219 | void BreakpointModel::removeBreakpointMarks(KTextEditor::Document& document) |
| 220 | { |