MCPcopy Create free account
hub / github.com/Serial-Studio/Serial-Studio / restoreProjectFromJson

Method restoreProjectFromJson

app/src/Sessions/Player.cpp:585–605  ·  view source on GitHub ↗

* @brief Loads the project JSON shipped by the worker. */

Source from the content-addressed store, hash-verified

583 * @brief Loads the project JSON shipped by the worker.
584 */
585bool Sessions::Player::restoreProjectFromJson(const QString& json)
586{
587 if (json.isEmpty())
588 return false;
589
590 QJsonParseError parseError{};
591 const auto doc = QJsonDocument::fromJson(json.toUtf8(), &parseError);
592 if (parseError.error != QJsonParseError::NoError || doc.isEmpty()) {
593 qWarning() << "[Sessions::Player] Embedded project JSON is malformed:"
594 << parseError.errorString();
595 return false;
596 }
597
598 AppState::instance().setOperationMode(SerialStudio::ProjectFile);
599 if (!DataModel::ProjectModel::instance().loadFromJsonDocument(doc)) {
600 qWarning() << "[Sessions::Player] ProjectModel rejected the embedded JSON";
601 return false;
602 }
603
604 return true;
605}
606
607//--------------------------------------------------------------------------------------------------
608// Progress & seeking

Callers

nothing calls this directly

Calls 5

fromJsonFunction · 0.85
isEmptyMethod · 0.80
errorStringMethod · 0.80
loadFromJsonDocumentMethod · 0.80
setOperationModeMethod · 0.45

Tested by

no test coverage detected