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

Method closeResources

app/src/Sessions/Export.cpp:79–111  ·  view source on GitHub ↗

* @brief Closes the database and finalizes the current session. */

Source from the content-addressed store, hash-verified

77 * @brief Closes the database and finalizes the current session.
78 */
79void Sessions::ExportWorker::closeResources()
80{
81 if (!m_dbOpen)
82 return;
83
84 finalizeSession();
85
86 TableSnapshotEntry staleSnapshot;
87 while (m_snapshotQueue->try_dequeue(staleSnapshot)) {
88 }
89
90 m_readingQuery.reset();
91 m_rawBytesQuery.reset();
92 m_tableSnapshotQuery.reset();
93
94 QString connName;
95 if (m_db) {
96 connName = m_db->connectionName();
97 QSqlQuery checkpoint(*m_db);
98 checkpoint.exec("PRAGMA wal_checkpoint(RESTART)");
99 m_db->close();
100 }
101
102 m_db.reset();
103 if (!connName.isEmpty())
104 QSqlDatabase::removeDatabase(connName);
105
106 m_dbOpen = false;
107 m_sessionId = -1;
108 m_lastRawBytesNs = -1;
109 m_schema = DataModel::ExportSchema{};
110 resetMonotonicClock();
111}
112
113/**
114 * @brief Returns whether the database file is open.

Callers

nothing calls this directly

Calls 5

execMethod · 0.80
isEmptyMethod · 0.80
try_dequeueMethod · 0.45
resetMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected