Opened 4 years ago

#1337 new defect

The Hemlock listener freezes when you try to paste text into a write-protected region

Reported by: mattb Owned by:
Priority: normal Milestone:
Component: IDE Version: trunk
Keywords: Cc:

Description

Steps to reproduce:

  1. Start Hemlock
  2. Press command-a to select all text in the listener window
  3. Press command-c to make sure you have text on your clipboard
  4. Press command-v

Why it causes the listener to freeze: The DELETE-CHARACTERS function is called in the -replaceCharactersInRange:withString: method of HEMLOCK-TEXT-STORAGE. That function calls CHECK-BUFFER-MODIFICATION to ensure the specified region in the buffer doesn't contain any write-protected text. When the region does contain write-protected text, EDITOR-ERROR is called. Normally that would just cause the message "Can't modify protected buffer region." to be displayed in the mini-buffer and abort the operation, but in this specific case the error falls through to the top-level I started Hemlock from. It's possible to recover from that error, but it leaves the buffer in an unusable state which keeps freezing if you try do anything with it except close the window.

Solution: Override the -shouldChangeTextInRange:replacementString: method of HEMLOCK-TEXTSTORAGE-TEXT-VIEW to perform the call to CHECK-BUFFER-MODIFICATION before DELETE-CHARACTERS does it, and if it causes an error, handle it more appropriately.

Attachments (1)

listener-freeze-fix.patch (883 bytes) - added by mattb 4 years ago.

Download all attachments as: .zip

Change History (1)

Changed 4 years ago by mattb

Note: See TracTickets for help on using tickets.