[Openmcl-devel] Does anybody know why (make-instance 'ns:ns-window) no longer works

Paul Krueger plkrueger at comcast.net
Thu Jul 8 06:19:36 PDT 2021


Most cocoa functions need to be run on the main event thread these days. You used to be able to get by without doing that for some things, but no longer.

Here is the code for a macro that I use, but the easygui package also contains similar things that you can use:

Clozure Common Lisp Version 1.12.1 (v1.12.1) DarwinX8664

For more information about CCL, please see http://ccl.clozure.com.

CCL is free software.  It is distributed under the terms of the Apache
Licence, Version 2.0.
? (make-instance 'ns:ns-window)
> Error: Objective-C runtime exception: 
>        NSWindow drag regions should only be invalidated on the Main Thread!
> While executing: #<Anonymous Function #x3000011B4FEF>, in process Listener(4).
> Type cmd-. to abort, cmd-\ for a list of available restarts.
> Type :? for other options.
1 > 
?
> Error: Can't modify protected buffer region.
> While executing: CCL::TOPLEVEL-EVAL, in process Listener(4).
> Type cmd-. to abort, cmd-\ for a list of available restarts.
> Type :? for other options.
1 > 
? (defmacro on-main-thread (&rest actions)
  `(ccl::call-in-event-process
     #'(lambda ()
         , at actions)))
ON-MAIN-THREAD
? (on-main-thread  (make-instance 'ns:ns-window))
#<NS-WINDOW <NSWindow: 0x600003e06b00> (#x600003E06B00)>
? 

> On Jul 7, 2021, at 4:03 PM, Richard Sutton <rsutton at ualberta.ca> wrote:
> 
> Hello Fellow CCLers, 
> 
> I have been away for a couple years, and now I found my Cocoa code no longer works. I traced it down to one of the Cocoa primitives I was relying on: ns:ns-window. In particular, I used to be able to just make an instance of this, but now i get:
> 
> ? (make-instance 'ns:ns-window)
>> Error: Objective-C runtime exception: 
>>       NSWindow drag regions should only be invalidated on the Main Thread!
>> While executing: #<Anonymous Function #x3000011BD76F>, in process Listener(4).
>> Type cmd-. to abort, cmd-\ for a list of available restarts.
>> Type :? for other options.
> 1 > 
> 
> Does anybody know what has happened or, more importantly, how to work around this problem?
> 
> Thanks for any leads, 
> rich
> _______________________________________________
> Openmcl-devel mailing list
> Openmcl-devel at clozure.com
> https://lists.clozure.com/mailman/listinfo/openmcl-devel




More information about the Openmcl-devel mailing list