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

Method closeDatabase

app/src/Sessions/DatabaseWorker.cpp:115–142  ·  view source on GitHub ↗

* @brief Closes the database, removes the connection, clears caches. */

Source from the content-addressed store, hash-verified

113 * @brief Closes the database, removes the connection, clears caches.
114 */
115void Sessions::DatabaseWorker::closeDatabase()
116{
117 m_cancelRequested.store(true, std::memory_order_release);
118
119 m_sessionList.clear();
120 m_tagList.clear();
121 m_passwordHash.clear();
122 m_locked = false;
123
124 if (QCoreApplication::instance()) {
125 if (m_db.isOpen()) {
126 QSqlQuery checkpoint(m_db);
127 checkpoint.exec("PRAGMA wal_checkpoint(RESTART)");
128 m_db.close();
129 }
130
131 const QString conn = m_connectionName;
132 m_db = QSqlDatabase();
133 if (!conn.isEmpty())
134 QSqlDatabase::removeDatabase(conn);
135 }
136
137 m_filePath.clear();
138 m_connectionName.clear();
139 m_cancelRequested.store(false, std::memory_order_release);
140
141 Q_EMIT closed();
142}
143
144/**
145 * @brief Re-runs every internal cache fetch and ships the results back.

Callers 1

onQuitMethod · 0.45

Calls 6

execMethod · 0.80
isEmptyMethod · 0.80
QSqlDatabaseClass · 0.70
clearMethod · 0.45
isOpenMethod · 0.45
closeMethod · 0.45

Tested by

no test coverage detected