Skip to content

serialbus: create connection timer in worker thread - #1099

Open
dry-75 wants to merge 1 commit into
collin80:QT6WIPfrom
dry-75:dry/QT6WIP_mr1
Open

dry-75 wants to merge 1 commit into
collin80:QT6WIPfrom
dry-75:dry/QT6WIP_mr1

Conversation

@dry-75

@dry-75 dry-75 commented May 25, 2026

Copy link
Copy Markdown

Please review

This fixes for me the following:

QObject: Cannot create children for a parent that is in a different thread.
(Parent is SerialBusConnection(0xf5738b0), parent's thread is QThread(0xf5c6cd0), current thread is QThread(0xee624e0)
QObject::startTimer: Timers cannot be started from another thread

Otherwise, no serial connection establishes / works - e.g. my case, passthrucan . If warnings as critical enabled, qt will abort and app dumps core.

With the change, i can use passthrucan and it loads my j2534.so.

Change SerialBusConnection's timer from a value member to a lazily
allocated QObject child created on first piStarted().

The base CANConnection constructor may move the connection object to its
worker thread before derived members are constructed. Under Qt6 this causes
cross-thread QObject child creation and timer start errors when QTimer is
parented during SerialBusConnection construction.

Create and start the timer only after the connection is running in its
worker thread.
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