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

Method addCommandWithCurrentSessionHandler

plugins/debuggercommon/midebugsession.h:483–503  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

481
482template<class Handler>
483void MIDebugSession::addCommandWithCurrentSessionHandler(MI::CommandType type, const QString& arguments,
484 Handler* handler_this,
485 MI::MICommand::ResultRecordMethod<Handler> handler_method,
486 MI::CommandFlags flags)
487{
488 auto cmd = createCommand(type, arguments, flags);
489
490 // Capture the QObject pointer instead of `this` to ensure safety in case the handler is
491 // invoked from ~MIDebugger(), which is invoked when this->~QObject() destroys child objects.
492 const QObject* const thisSession = this;
493 cmd->setHandler(new MI::FunctionCommandHandler(
494 [guarded_this = QPointer{handler_this}, handler_method, thisSession](const MI::ResultRecord& record) {
495 auto* const handler = guarded_this.get();
496 if (handler && isCurrentDebugSession(thisSession)) {
497 (handler->*handler_method)(record);
498 }
499 },
500 flags));
501
502 queueCmd(std::move(cmd));
503}
504
505} // end of namespace KDevMI
506

Callers 7

testCommandHandlerMethod · 0.80
setDisassemblyFlavorMethod · 0.80
updateRegistersMethod · 0.80
changeMemoryRangeMethod · 0.80
addReadMemoryCommandMethod · 0.80

Calls 2

setHandlerMethod · 0.60
getMethod · 0.45

Tested by 1

testCommandHandlerMethod · 0.64