Skip to content

liteeditor: fix macOS crash on empty selection IME query - #1378

Merged
visualfc merged 1 commit into
masterfrom
fix/macos-ime-selection-crash
Nov 14, 2026
Merged

visualfc merged 1 commit into
masterfrom
fix/macos-ime-selection-crash

Conversation

@visualfc

Copy link
Copy Markdown
Owner

Summary

Fix a macOS main-thread crash (EXC_BAD_ACCESS at 0x8) when Accessibility or the Services menu queries the focused editor with no text selected.

Qt 6 QWidgetTextControl::inputMethodQuery(ImCurrentSelection) calls createMimeDataFromSelection() and then deleteLater() on the result. LiteEditorWidget::createMimeDataFromSelection() returns null when nothing is selected, so this becomes null->deleteLater().

Override inputMethodQuery and return the current selection (including block selection) as text, so the Qt 6 null-pointer path is never taken. Copy still returns null from createMimeDataFromSelection() when there is no selection.

Test plan

  • Build LiteIDE with Qt 6 on macOS
  • Focus a code editor with no selection
  • Trigger Services/Accessibility inspection (VoiceOver, Accessibility Inspector, or sleep/wake with the editor focused)
  • Confirm the app no longer crashes
  • Confirm copy still no-ops when nothing is selected
  • Confirm copy/paste still works with a normal selection and with block selection

Qt 6 QWidgetTextControl::inputMethodQuery calls deleteLater() on the
QMimeData from createMimeDataFromSelection(). LiteEditorWidget returns
null when nothing is selected, so macOS accessibility/Services queries
crash with SIGSEGV at 0x8.

Handle ImCurrentSelection in inputMethodQuery and return the selected
text without going through createMimeDataFromSelection().
@visualfc
visualfc merged commit 174f80c into master Nov 14, 2026
12 checks passed
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