MCPcopy Create free account
hub / github.com/PlotJuggler/PlotJuggler / showDataSourceDialog

Function showDataSourceDialog

pj_app/src/DialogPresenter.cpp:49–79  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

47} // namespace
48
49DataSourceResult showDataSourceDialog(const DataSourceRequest& req) {
50 if ((req.source.capabilities & PJ_DATA_SOURCE_CAPABILITY_HAS_DIALOG) == 0) {
51 return {};
52 }
53
54 auto vtable_result = req.source.library.resolveDialogVtable();
55 if (!vtable_result) {
56 return contractViolation(req.source.name, "resolveDialogVtable failed: " + vtable_result.error());
57 }
58
59 const PJ_borrowed_dialog_t borrowed = req.handle.getDialog();
60 if (borrowed.ctx == nullptr) {
61 return contractViolation(req.source.name, "getDialog() returned null context");
62 }
63
64 DialogEngineConfig engine_config;
65 engine_config.parser_dialog_provider = makeParserDialogProvider(req.catalog);
66 // string-from-string_view ctor (C++17) handles a default-empty view safely;
67 // raw .assign(data(), size()) would be UB when data() is nullptr.
68 engine_config.initial_parser_config = std::string(req.initial_parser_config);
69
70 DialogEngine engine(DialogHandle::borrowed(*vtable_result, borrowed.ctx), std::move(engine_config));
71 if (engine.showDialog(req.parent) == DialogResult::kRejected) {
72 return {.outcome = Outcome::kRejected};
73 }
74
75 return {
76 .outcome = Outcome::kAccepted,
77 .payload = AcceptedPayload{.saved_config = engine.savedConfig(), .parser_config = engine.parserConfig()},
78 };
79}
80
81} // namespace PJ::dialog_presenter

Callers 2

beginLoadMethod · 0.85
startSessionMethod · 0.85

Calls 5

contractViolationFunction · 0.85
makeParserDialogProviderFunction · 0.85
showDialogMethod · 0.80
savedConfigMethod · 0.80
parserConfigMethod · 0.80

Tested by

no test coverage detected