chatgui: add SIGINT/SIGTERM handler (as in utun.c), save scroll pos on every debounce
Signal handler via g_shutdown + uasync_wakeup ensures clean uasync poll exit. updateReadPosition() now saves both lastReadMsgId and lastPosMsgId on every scroll stop (300ms debounce), not just when read position changes. connect(stopped, quit) triggers graceful Qt shutdown after uasync cleanup.
This commit is contained in:
1 parent
83ca0c65a4
commit
6cafff200b
3 files changed
+36
-11
No files matched your search
@@ -352,19 +352,28 @@ void MessageList::updateReadPosition() {
|
||||
newReadMsgId = msgId;
|
||||
}
|
||||
|
||||
QModelIndex topIdx = m_view->indexAt(QPoint(0, 0));
|
||||
qint64 lastPosMsgId = topIdx.isValid() ? topIdx.data(MsgIdRole).toLongLong() : 0;
|
||||
|
||||
DEBUG_DEBUG(DEBUG_CATEGORY_DEBUG,
|
||||
"MessageList::updateReadPosition ch=%s oldRead=%lld newRead=%lld lastVisRow=%d/%d",
|
||||
"MessageList::updateReadPosition ch=%s oldRead=%lld newRead=%lld pos=%lld lastVisRow=%d/%d",
|
||||
qPrintable(m_currentChannelId), (long long)m_lastReadMsgId,
|
||||
(long long)newReadMsgId, lastFullyVisibleRow, m_model->rowCount());
|
||||
(long long)newReadMsgId, (long long)lastPosMsgId,
|
||||
lastFullyVisibleRow, m_model->rowCount());
|
||||
|
||||
QByteArray cid = m_currentChannelId.toUtf8();
|
||||
|
||||
if (newReadMsgId > m_lastReadMsgId) {
|
||||
m_lastReadMsgId = newReadMsgId;
|
||||
|
||||
QByteArray cid = m_currentChannelId.toUtf8();
|
||||
QByteArray key = "ch_" + cid + "_last_read";
|
||||
QByteArray valStr = QByteArray::number(m_lastReadMsgId);
|
||||
chat_core_save_ui_state(key.constData(), valStr.constData());
|
||||
|
||||
emit readPositionChanged(m_currentChannelId, m_lastReadMsgId);
|
||||
}
|
||||
|
||||
if (lastPosMsgId > 0) {
|
||||
QByteArray posKey = "ch_" + cid + "_last_pos";
|
||||
QByteArray posVal = QByteArray::number(lastPosMsgId);
|
||||
chat_core_save_ui_state(posKey.constData(), posVal.constData());
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user