chatgui: synchronous DB write in saveChannelState/updateReadPosition, add shutdown debug logs

Replace gui_bridge_post_uasync_fn (async queue lost on shutdown) with direct
chat_core_save_ui_state (sync SQLite write). SQLite WAL handles concurrent access.
Add DEBUG_DEBUG traces in closeEvent, ~MainWindow, aboutToQuit.
This commit is contained in:
Evgeny committed 2026-07-24 03:29:37 +03:00
1 parent 393b7d36c8
commit fdc30d1a4e
2 files changed
+9 -16

No files matched your search

+2 -15
View File
@@ -302,13 +302,7 @@ void MessageList::saveChannelState() {
auto saveKey = [&cid](const char* suffix, qint64 val) {
QByteArray key = "ch_" + cid + suffix;
QByteArray valStr = QByteArray::number(val);
size_t klen = key.size(), vlen = valStr.size();
size_t total = klen + 1 + vlen + 1;
if (total > 256) return;
void* arg = u_malloc(total);
memcpy(arg, key.constData(), klen + 1);
memcpy((char*)arg + klen + 1, valStr.constData(), vlen + 1);
gui_bridge_post_uasync_fn(chat_core_save_ui_state_trampoline, arg);
chat_core_save_ui_state(key.constData(), valStr.constData());
};
if (lastReadMsgId > 0) saveKey("_last_read", lastReadMsgId);
@@ -369,14 +363,7 @@ void MessageList::updateReadPosition() {
QByteArray cid = m_currentChannelId.toUtf8();
QByteArray key = "ch_" + cid + "_last_read";
QByteArray valStr = QByteArray::number(m_lastReadMsgId);
size_t klen = key.size(), vlen = valStr.size();
size_t total = klen + 1 + vlen + 1;
if (total <= 256) {
void* arg = u_malloc(total);
memcpy(arg, key.constData(), klen + 1);
memcpy((char*)arg + klen + 1, valStr.constData(), vlen + 1);
gui_bridge_post_uasync_fn(chat_core_save_ui_state_trampoline, arg);
}
chat_core_save_ui_state(key.constData(), valStr.constData());
emit readPositionChanged(m_currentChannelId, m_lastReadMsgId);
}