Skip to content

fix(dmr): MSTCL/MSTNAK reconnect never fires#16

Open
USA-RedDragon wants to merge 1 commit intonostar:mainfrom
USA-RedDragon:main
Open

fix(dmr): MSTCL/MSTNAK reconnect never fires#16
USA-RedDragon wants to merge 1 commit intonostar:mainfrom
USA-RedDragon:main

Conversation

@USA-RedDragon
Copy link
Copy Markdown

When receiving MSTCL or MSTNAK, the DMR mode object emits two cross-thread signals: request_connect_toggle() to disconnect, and request_reconnect() to schedule a 10-second reconnect timer.

Because the mode object lives on m_modethread while DroidStar lives on the main thread, both signals use Qt::QueuedConnection. They are delivered in the order they were emitted. The original code emitted request_connect_toggle() first, which queued process_connect() on the main thread. When that slot ran, it called m_modethread->quit(), which triggered the thread's finished() signal, which invoked m_mode->deleteLater(). By the time the event loop got to the second queued signal (request_reconnect), the sender object was already destroyed and Qt had silently disconnected it, so schedule_reconnect() was never called.

This fix swaps the emit order so request_reconnect() is queued first. The main thread event loop then processes schedule_reconnect() (which just starts a QTimer::singleShot) before process_connect() tears down the mode object.

When receiving MSTCL or MSTNAK, the DMR mode object emits two
cross-thread signals: `request_connect_toggle()` to disconnect, and
`request_reconnect()` to schedule a 10-second reconnect timer.

Because the mode object lives on `m_modethread` while DroidStar lives on
the main thread, both signals use `Qt::QueuedConnection`. They are
delivered in the order they were emitted. The original code emitted
`request_connect_toggle()` first, which queued `process_connect()` on the
main thread. When that slot ran, it called `m_modethread->quit()`, which
triggered the thread's `finished()` signal, which invoked
`m_mode->deleteLater()`. By the time the event loop got to the second queued
signal (`request_reconnect`), the sender object was already destroyed and Qt
had silently disconnected it, so `schedule_reconnect()` was never called.

This fix swaps the emit order so `request_reconnect()` is queued first. The
main thread event loop then processes `schedule_reconnect()` (which just starts
a `QTimer::singleShot`) before `process_connect()` tears down the mode object.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant