Use the running profile database directory for desktop media paths
This commit is contained in:
1 parent
b87050900c
commit
0942bf3d24
3 files changed
+9
No files matched your search
@@ -525,6 +525,7 @@ void MainWindow::setupBridgeCallbacks() {
|
||||
auto* database = node ? node->databaseHandle() : nullptr;
|
||||
if (!database) { DEBUG_WARN(DEBUG_CATEGORY_SYS, "desktop DB_READY ignored while core unavailable/stopping"); return; }
|
||||
s_mainWindow->m_db->setDb(database);
|
||||
s_mainWindow->m_db->setDbPath(node->databasePath());
|
||||
s_mainWindow->m_db->setMyNodeId(node->nodeIdHex().toULongLong(nullptr, 16));
|
||||
if (AvatarManager::instance()) AvatarManager::instance()->initialize();
|
||||
RadioAudioEngine::instance()->loadSettings(s_mainWindow->m_cfgPath);
|
||||
|
||||
@@ -126,6 +126,11 @@ struct sqlite3* UtunNode::databaseHandle() const {
|
||||
return m_stopping ? nullptr : m_snapshot.database;
|
||||
}
|
||||
|
||||
QString UtunNode::databasePath() const {
|
||||
std::lock_guard<std::mutex> guard(m_snapshotMutex);
|
||||
return m_snapshot.databasePath;
|
||||
}
|
||||
|
||||
void UtunNode::finalize() {
|
||||
gui_bridge_set_inst(nullptr);
|
||||
gui_bridge_set_uasync(nullptr);
|
||||
@@ -169,6 +174,7 @@ void UtunNode::updateSnapshot(const UTUN_INSTANCE* inst) {
|
||||
std::lock_guard<std::mutex> guard(m_snapshotMutex);
|
||||
if (!inst) { m_snapshot = {}; return; }
|
||||
m_snapshot.database = inst->topo_sqlite_db;
|
||||
m_snapshot.databasePath = QString::fromUtf8(inst->config->global.db_path);
|
||||
if (m_snapshot.nodeId.isEmpty()) {
|
||||
char id[17]; snprintf(id, sizeof(id), "%016" PRIx64, inst->node_id);
|
||||
m_snapshot.nodeId = QString::fromLatin1(id);
|
||||
|
||||
@@ -48,6 +48,7 @@ public:
|
||||
/* GUI: заимствованный handle, живой до stopping; после сигнала новые чтения запрещены.
|
||||
* Слот stopping снимает handle без вызова stop/join. Worker ждёт завершения слотов перед destroy. */
|
||||
struct sqlite3* databaseHandle() const;
|
||||
QString databasePath() const; // Копия фактического каталога db_path ядра; пусто без instance.
|
||||
|
||||
// Копии данных ядра, безопасны вне uasync; до старта/после stop — пустые строки, 0/false.
|
||||
QString nodeIdHex() const;
|
||||
@@ -73,6 +74,7 @@ private:
|
||||
int64_t ntpOffsetUs = 0;
|
||||
bool ntpSynced = false, ntpEnabled = false;
|
||||
struct sqlite3* database = nullptr; // Заимствован до подтверждения stopping в GUI.
|
||||
QString databasePath; // Каталог SQLite/media после применения GUI override.
|
||||
} m_snapshot; // Копия для GUI; доступ под m_snapshotMutex, указателей ядра не содержит.
|
||||
mutable std::mutex m_snapshotMutex;
|
||||
std::atomic<UTUN_INSTANCE*> m_instance{nullptr}; // Публикуется после готовности; не продлевает жизнь ядра.
|
||||
|
||||
Reference in new issue
Block a user