MCPcopy Create free account
hub / github.com/KDE/kdevelop / markChanged

Method markChanged

kdevplatform/debugger/breakpoint/breakpointmodel.cpp:559–610  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

557}
558
559void BreakpointModel::markChanged(KTextEditor::Document* document, KTextEditor::Mark mark,
560 KTextEditor::Document::MarkChangeAction action)
561{
562 Q_D(const BreakpointModel);
563
564 int type = mark.type;
565 /* Is this a breakpoint mark, to begin with? */
566 if (!(type & AllBreakpointMarks)) return;
567
568 // This slot's only purpose is to add or remove a breakpoint in response to explicit user action.
569 // Therefore, the slot is inhibited and returns early when invoked during programmatic mark changes.
570 // TODO: in certain rare and unlikely scenarios, such as a call to KTextEditor::Document::setText(),
571 // this slot is not inhibited when it should be. As a result, some breakpoint data (e.g. enabled
572 // state, line number or breakpoint condition) can be lost. Changes in KTextEditor implementation
573 // and even API additions are necessary to ensure proper inhibition.
574
575 if (d->inhibitMarkChange)
576 return;
577
578 Q_ASSERT_X(!document->url().isEmpty(), Q_FUNC_INFO,
579 "Somehow a breakpoint mark appeared in an untitled/unsaved document. This is not supported.");
580
581 if (action == KTextEditor::Document::MarkAdded) {
582 Breakpoint *b = breakpoint(document->url(), mark.line);
583 if (b) {
584 // This happens when the user Ctrl+clicks a mark of a breakpoint type
585 // other than BreakpointActive (e.g. BreakpointDisabled) on a text editor border.
586 // Delete the found breakpoint instance.
587 removeBreakpoint(b);
588 return;
589 }
590 // This happens when the user Ctrl+clicks a mark-less place of
591 // a text editor border or adds a new breakpoint via the mark context menu.
592 addCodeBreakpoint(document->url(), mark.line);
593 } else {
594 // This happens when the user Ctrl+clicks a BreakpointActive mark on a text editor border.
595 // Find this breakpoint instance and delete it.
596 Breakpoint *b = breakpoint(document->url(), mark.line);
597 if (b) {
598 removeBreakpoint(b);
599 }
600 }
601
602#if 0
603 if ( KDevelop::ICore::self()->documentController()->activeDocument() && KDevelop::ICore::self()->documentController()->activeDocument()->textDocument() == document )
604 {
605 //bring focus back to the editor
606 // TODO probably want a different command here
607 KDevelop::ICore::self()->documentController()->activateDocument(KDevelop::ICore::self()->documentController()->activeDocument());
608 }
609#endif
610}
611
612static constexpr int breakpointMarkPixmapSize = 32;
613

Callers

nothing calls this directly

Calls 6

activeDocumentMethod · 0.80
documentControllerMethod · 0.80
activateDocumentMethod · 0.80
isEmptyMethod · 0.45
urlMethod · 0.45
textDocumentMethod · 0.45

Tested by

no test coverage detected