Reserve desktop edit dispatch and reject malformed update events
This commit is contained in:
1 parent
5b6c96d3d8
commit
8523448c3a
3 files changed
+17
-1
No files matched your search
@@ -696,7 +696,7 @@ MessageList::MessageList(DbManager* db, AudioRecorder* recorder, QWidget *parent
|
||||
snprintf(req->channel_id, sizeof(req->channel_id), "%s", channel.toUtf8().constData());
|
||||
memcpy(req->message_id, id.constData(), 32); req->data = (uint8_t*)(req + 1); req->data_len = bytes.size();
|
||||
memcpy(req->data, bytes.constData(), bytes.size());
|
||||
gui_bridge_post_uasync_fn(chat_core_submit_trampoline, req);
|
||||
if (gui_bridge_submit_message(req) < 0) { u_free(req); m_inputBar->submissionResult(request, false); }
|
||||
});
|
||||
connect(m_inputBar, &InputBar::sendMessage, this, [this](const QString &text, const QByteArray& reply, quint64 request) {
|
||||
if (!gui_bridge_get_inst() || !gui_bridge_is_uasync_ready()) {
|
||||
|
||||
@@ -78,6 +78,9 @@ void gui_bridge_post(int event_type, const uint8_t* data, int data_len);
|
||||
/* GUI → uasync: передать fn(arg). Проверить готовность заранее: без ua запрос отбрасывается,
|
||||
* функция не вызывается и arg не освобождается мостом. */
|
||||
void gui_bridge_post_uasync_fn(void (*fn)(void*), void* arg);
|
||||
/* Зарезервировать доставку composer-запроса. 0 — владение req перешло ядру; -1 — req остаётся вызывающему. */
|
||||
struct chat_msg_submit;
|
||||
int gui_bridge_submit_message(struct chat_msg_submit* req);
|
||||
|
||||
/* Проверить готовность uasync (g_ua != NULL) */
|
||||
int gui_bridge_is_uasync_ready(void);
|
||||
|
||||
@@ -107,6 +107,9 @@ void GuiBridgeReceiver::processPost(int eventType, QByteArray data) {
|
||||
g_network_changed_cb(eventType);
|
||||
switch (eventType) {
|
||||
case CHAT_EVT_MSG_UPDATED:
|
||||
if (dlen < 34 || !d[0] || dlen != 1 + d[0] + 32) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_CHAT, "invalid message update bytes=%d", dlen); break;
|
||||
}
|
||||
if (g_msg_updated_cb) g_msg_updated_cb(d, dlen);
|
||||
break;
|
||||
case CHAT_EVT_RADIO_CALL:
|
||||
@@ -536,6 +539,16 @@ void gui_bridge_post_uasync_fn(void (*fn)(void*), void* arg) {
|
||||
uasync_post(g_ua, fn, arg);
|
||||
}
|
||||
|
||||
int gui_bridge_submit_message(struct chat_msg_submit* req) {
|
||||
if (!req || !g_inst || !g_ua || !uasync_is_running(g_ua)) {
|
||||
DEBUG_ERROR(DEBUG_CATEGORY_CHAT_SYNC, "composer submission: core unavailable"); return -1;
|
||||
}
|
||||
auto* post = static_cast<posted_task*>(u_calloc(1, sizeof(posted_task)));
|
||||
if (!post) { DEBUG_ERROR(DEBUG_CATEGORY_CHAT_SYNC, "composer submission: post allocation failed"); return -1; }
|
||||
req->inst = g_inst; post->callback = chat_core_submit_trampoline; post->arg = req; uasync_post_reserved(g_ua, post);
|
||||
return 0;
|
||||
}
|
||||
|
||||
int gui_bridge_is_uasync_ready(void) {
|
||||
return g_ua != NULL ? 1 : 0;
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user