Lisp HUG Maillist Archive

Properly closing CAPI Application on macOS

Hello,

I am trying to figure out how to properly close a CAPI application on macOS.

I have the following for a :destroy-callback:

(defun main-destroy-callback (pane &rest args)
  (capi:quit-interface pane))

But using this (or simply (lispworks:quit)) gives the following type of error:

Reactor:~ burton$ /var/tmp/lwtemp_Reactor_65151ZYH9TF.command ; exit;

Error: Segmentation violation(11) [code 0] at 7FFFE29EA01D
        Foreign code offset #x1D from symbol "objc_msgSend"
        module "/usr/lib/libobjc.A.dylib" [ #x7FFFE29E3000 ]
rax 600000037560 ; rbx 7FFFE8A8BE60 ; rcx         1174 ; rdx         1173
rsp 7FFF5FBFE0A8 ; rbp 7FFF5FBFE0B0 ; rdi    100324ED0 ; rsi 7FFFCBEFBBD6
r8  618000040CF0 ; r9  21EB0D26C23AE422 ; r10            0 ; r11 7FFFCBEFBBD6
r12 6300000230A0 ; r13            0 ; r14 600000033200 ; r15 600000044470
  1 (abort) Return to Cocoa Event Loop

Type :b for backtrace or :c <option number> to proceed.
Type :bug-form "<subject>" for a bug report template or :? for other options.

CL-USER 1 : 1 > 

How does one properly close a CAPI application?

—
Burton Samograd
BusFactor1 Inc.
http://busfactor1.ca/

Re: Properly closing CAPI Application on macOS

Here’s how I did it in one of my routinely used apps:

(capi:define-interface messaging-intf ()
  ()
  (:panes
   (msg-text-pane msg-editor-pane
                     :text ""
                     :buffer-name "PlainCryptoText"
                     :title "Plain/Encoded Text"
                     :title-position :top
                     :title-args '(:visible-min-width (:character 20)
                                   :visible-max-width t)
                     :visible-min-width '(:character 85)
                     :visible-max-width nil
                     :visible-min-height '(:character 20)
                     :visible-max-height nil
                     :drop-callback 'enc/dec-drop-callback
                     :accessor msg-text-pane)

   (msg-encode-button capi:push-button
                       :text "Encode"
                       #+:MSWINDOWS :drop-callback #+:MSWINDOWS 'enc-drop-callback
                       :callback 'encode-message)

   (msg-decode-button capi:push-button
                       :text "Decode"
                       #+:MSWINDOWS :drop-callback #+:MSWINDOWS 'dec-drop-callback
                       :callback 'decode-message)
   
   (cancel-button capi:push-button
                  :text "Cancel"
                  :callback (lambda (x intf)
                              (declare (ignore x))
                              (capi:destroy intf)))
   )
  
  (:layouts

   (row-layout1
    capi:row-layout
    '(msg-encode-button
      msg-decode-button
      nil
      cancel-button))

   (column-layout1
    capi:column-layout
    '(msg-text-pane
      row-layout1))
   )
  (:menu-bar file-menu edit-menu)
  (:menus
   (file-menu
    "File"
    (("Encode..."     :data :encode-file)
     ("Decode..."     :data :decode-file))
    :callback 'do-enc/dec-file)
   (edit-menu
    "Edit"
    (("Cut"        :data :cut  )
     ("Copy"       :data :copy )
     ("Paste"      :data :paste)
     ("Select All" :data :select-all
                   :accelerator "accelerator-a"))
    :callback 'do-menu-item
    #|:callback-type :item|#))

  (:default-initargs
   :layout 'column-layout1
   :title "RAL AONT Messaging"
   :best-width 400
   :window-styles '( #+:COCOA :textured-background
                              :movable-by-window-background)
   ;; :drop-callback 'top-level-drop-callback
   ))



On Apr 14, 2017, at 18:47, BusFactor1 Inc. <busfactor1@gmail.com> wrote:

Hello,

I am trying to figure out how to properly close a CAPI application on macOS.

I have the following for a :destroy-callback:

(defun main-destroy-callback (pane &rest args)
  (capi:quit-interface pane))

But using this (or simply (lispworks:quit)) gives the following type of error:

Reactor:~ burton$ /var/tmp/lwtemp_Reactor_65151ZYH9TF.command ; exit;

Error: Segmentation violation(11) [code 0] at 7FFFE29EA01D
        Foreign code offset #x1D from symbol "objc_msgSend"
        module "/usr/lib/libobjc.A.dylib" [ #x7FFFE29E3000 ]
rax 600000037560 ; rbx 7FFFE8A8BE60 ; rcx         1174 ; rdx         1173
rsp 7FFF5FBFE0A8 ; rbp 7FFF5FBFE0B0 ; rdi    100324ED0 ; rsi 7FFFCBEFBBD6
r8  618000040CF0 ; r9  21EB0D26C23AE422 ; r10            0 ; r11 7FFFCBEFBBD6
r12 6300000230A0 ; r13            0 ; r14 600000033200 ; r15 600000044470
  1 (abort) Return to Cocoa Event Loop

Type :b for backtrace or :c <option number> to proceed.
Type :bug-form "<subject>" for a bug report template or :? for other options.

CL-USER 1 : 1 > 

How does one properly close a CAPI application?

—
Burton Samograd
BusFactor1 Inc.
http://busfactor1.ca/

Re: Properly closing CAPI Application on macOS

Hi,

Please take a look at one of examples of CAPI OSX applications - there
was some example and explanations, don't remember details, but there was
some issue to clear pointers of interface and window to each other
before doing destroy. (destroy, not quit-interface).


"BusFactor1 Inc." <busfactor1@gmail.com> writes:

> Hello,
>
> I am trying to figure out how to properly close a CAPI application on macOS.
>
> I have the following for a :destroy-callback:
>
> (defun main-destroy-callback (pane &rest args)
> (capi:quit-interface pane))
>
> But using this (or simply (lispworks:quit)) gives the following type of error:
>
> Reactor:~ burton$ /var/tmp/lwtemp_Reactor_65151ZYH9TF.command ; exit;
>
> Error: Segmentation violation(11) [code 0] at 7FFFE29EA01D
> Foreign code offset #x1D from symbol "objc_msgSend"
> module "/usr/lib/libobjc.A.dylib" [ #x7FFFE29E3000 ]
> rax 600000037560 ; rbx 7FFFE8A8BE60 ; rcx 1174 ; rdx 1173
> rsp 7FFF5FBFE0A8 ; rbp 7FFF5FBFE0B0 ; rdi 100324ED0 ; rsi 7FFFCBEFBBD6
> r8 618000040CF0 ; r9 21EB0D26C23AE422 ; r10 0 ; r11 7FFFCBEFBBD6
> r12 6300000230A0 ; r13 0 ; r14 600000033200 ; r15 600000044470
> 1 (abort) Return to Cocoa Event Loop
>
> Type :b for backtrace or :c <option number> to proceed.
> Type :bug-form "<subject>" for a bug report template or :? for other options.
>
> CL-USER 1 : 1 > 
>
> How does one properly close a CAPI application?
>
> —
> Burton Samograd
> BusFactor1 Inc.
> http://busfactor1.ca/
>

-- 
Br,
/Alexey

_______________________________________________
Lisp Hug - the mailing list for LispWorks users
lisp-hug@lispworks.com
http://www.lispworks.com/support/lisp-hug.html

Updated at: 2020-12-10 08:31 UTC