| 341 | } |
| 342 | |
| 343 | void DebugController::clearExecutionPoint() |
| 344 | { |
| 345 | const auto* const documentController = KDevelop::ICore::self()->documentController(); |
| 346 | if (!documentController) { |
| 347 | qCDebug(SHELL) << "Cannot clear execution point without the document controller. " |
| 348 | "KDevelop must be exiting and the document controller already destroyed."; |
| 349 | return; |
| 350 | } |
| 351 | |
| 352 | auto* const document = m_lastExecMarkDocument.data(); |
| 353 | // Do we even have a document with execution mark? |
| 354 | if (!document) { |
| 355 | return; |
| 356 | } |
| 357 | m_lastExecMarkDocument = nullptr; |
| 358 | |
| 359 | constexpr auto markTypeToRemove = executionMark; |
| 360 | |
| 361 | // Is the execution mark still at the line it was added to? |
| 362 | if (document->mark(m_lastExecMarkLine) & markTypeToRemove) { |
| 363 | document->removeMark(m_lastExecMarkLine, markTypeToRemove); |
| 364 | return; |
| 365 | } |
| 366 | |
| 367 | // The execution mark is on some other line (probably because the document was edited |
| 368 | // during the current debug session). Iterate over all marks in the document to find and remove it. |
| 369 | const auto& marks = document->marks(); |
| 370 | const auto it = std::find_if(marks.begin(), marks.end(), [](const KTextEditor::Mark* mark) -> bool { |
| 371 | // TODO: remove the following line once building KDevelop with Visual Studio 2019 is no longer supported. |
| 372 | constexpr auto markTypeToRemove = executionMark; |
| 373 | return mark->type & markTypeToRemove; |
| 374 | }); |
| 375 | |
| 376 | if (it != marks.end()) { |
| 377 | document->removeMark(it.key(), markTypeToRemove); |
| 378 | return; |
| 379 | } |
| 380 | |
| 381 | qCWarning(SHELL) << "failed to remove execution mark from" << document->url().toString(QUrl::PreferLocalFile); |
| 382 | } |
| 383 | |
| 384 | void DebugController::showStepInSource(const QUrl& originalUrl, int originalLine) |
| 385 | { |