* @brief Loads the project JSON shipped by the worker. */
| 583 | * @brief Loads the project JSON shipped by the worker. |
| 584 | */ |
| 585 | bool 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 |
nothing calls this directly
no test coverage detected