fix(dmr): MSTCL/MSTNAK reconnect never fires#16
Open
USA-RedDragon wants to merge 1 commit intonostar:mainfrom
Open
fix(dmr): MSTCL/MSTNAK reconnect never fires#16USA-RedDragon wants to merge 1 commit intonostar:mainfrom
USA-RedDragon wants to merge 1 commit intonostar:mainfrom
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
When receiving MSTCL or MSTNAK, the DMR mode object emits two cross-thread signals:
request_connect_toggle()to disconnect, andrequest_reconnect()to schedule a 10-second reconnect timer.Because the mode object lives on
m_modethreadwhile DroidStar lives on the main thread, both signals useQt::QueuedConnection. They are delivered in the order they were emitted. The original code emittedrequest_connect_toggle()first, which queuedprocess_connect()on the main thread. When that slot ran, it calledm_modethread->quit(), which triggered the thread'sfinished()signal, which invokedm_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, soschedule_reconnect()was never called.This fix swaps the emit order so
request_reconnect()is queued first. The main thread event loop then processesschedule_reconnect()(which just starts aQTimer::singleShot) beforeprocess_connect()tears down the mode object.