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

Function applyAndDiff

pj_dialog_host/src/dialog_engine.cpp:59–88  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57};
58
59static ApplyResult applyAndDiff(
60 QWidget* root, PJ::DialogHandle& handle, nlohmann::json& prev_data, bool enable_diff, int& diff_apply_count) {
61 std::string raw = handle.widget_data();
62 nlohmann::json new_data = nlohmann::json::parse(raw, nullptr, false);
63 if (new_data.is_discarded()) {
64 return {};
65 }
66
67 PJ::WidgetDataView full_view(raw);
68 ApplyResult result;
69 result.wants_accept = full_view.requestAccept();
70 result.sub_dialog_ui = full_view.subDialogUi();
71
72 // Strip commands before diffing (they're one-shot)
73 new_data.erase("__request_accept");
74 new_data.erase("__request_sub_dialog");
75
76 if (enable_diff) {
77 nlohmann::json diff = computeDiff(prev_data, new_data);
78 if (!diff.empty()) {
79 PJ::WidgetDataView view(diff.dump());
80 applyWidgetData(root, view);
81 ++diff_apply_count;
82 }
83 } else {
84 applyWidgetData(root, full_view);
85 }
86 prev_data = std::move(new_data);
87 return result;
88}
89
90// ---------------------------------------------------------------------------
91// show_dialog

Callers 2

showDialogMethod · 0.85
forwardEventMethod · 0.85

Calls 6

parseFunction · 0.85
computeDiffFunction · 0.85
applyWidgetDataFunction · 0.85
widget_dataMethod · 0.80
eraseMethod · 0.80
emptyMethod · 0.45

Tested by

no test coverage detected