[Openmcl-devel] Hemlock and its documents and windows

Chris Hanson cmhanson at eschatologist.net
Wed Oct 12 18:58:39 PDT 2016

On Oct 12, 2016, at 7:43 AM, Arthur Cater <arthur.cater at ucd.ie> wrote:
> On my mid-2015 Macbook Pro with OS X.11.5 I have been trying to move my code
> from DarwinX8664 ccl 1.10 r16196 to ccl 1.11 r16635.
> I have a problem with some code I contributed a few years back, clickable.lisp.
> Specifically it uses gui::find-or-make-hemlock-view and then  (hold your noses here)
> changes the ns:isa slot of the window to a subclass of gui::hemlock-frame and
> changes the ns:isa slot of the document to a subclass of guy::hemlock-editor-document.
> While the first seems to succeed, the second seems to cause a crash in ccl 1.11.
> I notice that the original contents of these ns:isa slots are now foreign pointers, whereas previously in ccl 1.10 they were ns class objects. I also notice that sometime between
> my developing that code and ccl 1.10 coming along, a change was made to the
> hemlock-frame’s ns:isa to be a #<NS-OBJECT NSKVONotifying_HemlockFrame …>.
> So I have a few questions, I’d love to hear your helpful answers!
> Is there a better way to get the effect of change-class on a NS object than to change its NS:ISA slot?
> If I am to change the slot, what sort of value should be used? If a foreign pointer, then
> how do I make an appropriate one (I only know of ccl::%int-to-ptr but that probably isn’t
> appropriate and if it is then I don’t know how to get the appropriate int)
> Where is that NSKVONotifying_HemlockFrame defined? Where is it used? Searches of the ccl files don’t show me anything relevant.

When you see an Objective-C class with a name starting with NSKVONotifying_, it’s because Key-Value Observing has swizzled the isa of the class itself to intercept getter/setter calls and post notifications to observers on its behalf. This can happen for any instance of a class that is observed, and of course Cocoa itself can add observers, they don’t just have to be in developer code.

That would probably also explain why your own isa-swizzling has stopped working, whatever change to the isa you’re making isn’t compatible with KVO’s own changes to the isa.

  -- Chris

More information about the Openmcl-devel mailing list