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

Method openLocalDb

app/src/Sessions/Player.cpp:455–480  ·  view source on GitHub ↗

* @brief Opens a main-thread @c QSqlDatabase connection used for per-frame queries. */

Source from the content-addressed store, hash-verified

453 * @brief Opens a main-thread @c QSqlDatabase connection used for per-frame queries.
454 */
455bool Sessions::Player::openLocalDb(const QString& filePath)
456{
457 m_connectionName = QStringLiteral("ss_sqlite_player_%1").arg(QDateTime::currentMSecsSinceEpoch());
458
459 m_db.emplace(QSqlDatabase::addDatabase("QSQLITE", m_connectionName));
460 m_db->setDatabaseName(filePath);
461 if (!m_db->open()) {
462 Misc::Utilities::showMessageBox(tr("Cannot open session file"),
463 tr("Check file permissions and try again."),
464 QMessageBox::Critical);
465 const QString conn = m_connectionName;
466 m_db.reset();
467 if (!conn.isEmpty())
468 QSqlDatabase::removeDatabase(conn);
469
470 m_connectionName.clear();
471 return false;
472 }
473
474 QSqlQuery pragma(*m_db);
475 pragma.exec("PRAGMA journal_mode=WAL");
476 pragma.exec("PRAGMA busy_timeout=5000");
477
478 detectFinalValueColumns();
479 return true;
480}
481
482/**
483 * @brief Probes the readings schema for the final-value columns (absent in old session files).

Callers

nothing calls this directly

Calls 5

isEmptyMethod · 0.80
execMethod · 0.80
openMethod · 0.45
resetMethod · 0.45
clearMethod · 0.45

Tested by

no test coverage detected