Skip to content

fix(bluetooth): use deleteLater() instead of delete on device removal - #1059

Open
andckadir wants to merge 1 commit into
quickshell-mirror:masterfrom
andckadir:andckadir-patch-1
Open

andckadir wants to merge 1 commit into
quickshell-mirror:masterfrom
andckadir:andckadir-patch-1

Conversation

@andckadir

Copy link
Copy Markdown

Synchronously deleting BluetoothDevice and BluetoothAdapter with raw
'delete' inside Bluez::onInterfacesRemoved causes a segmentation fault
(SIGSEGV in libQt6QmlModels.so) when a device is unpaired or removed.

When adapter->devices()->removeObject(device) is called, Qt Quick delegate
models and Repeaters bound to the devices list begin teardown and process
model updates. Immediate deletion frees the QObject while active QML
contexts (QQmlDelegateModelItem / QQmlContextData) still reference it
during that event loop cycle.

Using deleteLater() defers deallocation until the event loop finishes
pending QML signal disconnections and delegate cleanups safely.

 Synchronously deleting BluetoothDevice and BluetoothAdapter with raw
    'delete' inside Bluez::onInterfacesRemoved causes a segmentation fault
    (SIGSEGV in libQt6QmlModels.so) when a device is unpaired or removed.
  
    When adapter->devices()->removeObject(device) is called, Qt Quick delegate
    models and Repeaters bound to the devices list begin teardown and process
    model updates. Immediate deletion frees the QObject while active QML
    contexts (QQmlDelegateModelItem / QQmlContextData) still reference it
    during that event loop cycle.
  
    Using deleteLater() defers deallocation until the event loop finishes
    pending QML signal disconnections and delegate cleanups safely.
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