* @brief Worker shipped session bundle -- finalize setup on the main thread. */
| 357 | * @brief Worker shipped session bundle -- finalize setup on the main thread. |
| 358 | */ |
| 359 | void Sessions::Player::onLoadFinished(const PlayerSessionPayloadPtr& payload) |
| 360 | { |
| 361 | if (!payload || m_filePath.isEmpty()) { |
| 362 | if (m_loading) { |
| 363 | m_loading = false; |
| 364 | Q_EMIT loadingChanged(); |
| 365 | } |
| 366 | |
| 367 | return; |
| 368 | } |
| 369 | |
| 370 | if (payload->filePath != m_filePath) |
| 371 | return; |
| 372 | |
| 373 | if (m_pendingSessionId >= 0 && payload->sessionId != m_pendingSessionId) { |
| 374 | if (m_loading) { |
| 375 | m_loading = false; |
| 376 | Q_EMIT loadingChanged(); |
| 377 | } |
| 378 | |
| 379 | return; |
| 380 | } |
| 381 | |
| 382 | if (!payload->ok) { |
| 383 | Misc::Utilities::showMessageBox(tr("Cannot open session file"), |
| 384 | payload->error.isEmpty() ? tr("Unknown error") : payload->error, |
| 385 | QMessageBox::Critical); |
| 386 | |
| 387 | m_loading = false; |
| 388 | Q_EMIT loadingChanged(); |
| 389 | teardownLocalDb(); |
| 390 | clearLocalState(); |
| 391 | restorePreSessionState(); |
| 392 | Q_EMIT openChanged(); |
| 393 | Q_EMIT playerStateChanged(); |
| 394 | return; |
| 395 | } |
| 396 | |
| 397 | if (!payload->projectJson.isEmpty()) { |
| 398 | (void)restoreProjectFromJson(payload->projectJson); |
| 399 | } else { |
| 400 | Misc::Utilities::showMessageBox(tr("No project data"), |
| 401 | tr("This session does not contain an embedded project file — " |
| 402 | "the dashboard falls back to a quick-plot layout."), |
| 403 | QMessageBox::Warning); |
| 404 | } |
| 405 | |
| 406 | if (!openLocalDb(m_filePath)) { |
| 407 | m_loading = false; |
| 408 | Q_EMIT loadingChanged(); |
| 409 | clearLocalState(); |
| 410 | restorePreSessionState(); |
| 411 | Q_EMIT openChanged(); |
| 412 | Q_EMIT playerStateChanged(); |
| 413 | return; |
| 414 | } |
| 415 | |
| 416 | m_sessionId = payload->sessionId; |
nothing calls this directly
no test coverage detected