Lisp HUG Maillist Archive

LWM: ENSURE-OBJC-INITIALIZED causes SEGV / Creating a pure Cocoa app

Hello,

I'm trying to create a "pure" Cocoa app (i.e. one which uses  
NSApplication and its event loop) with LWM 4.4.5 on Mac OS X 10.4.1.  
Has anyone out there tried something like this with success?

So far all my attempts have resulted in an app which dies while  
calling (objc:ensure-objc-initialized ...)

Error: Signal : segmentation violation(11)

Type :b for backtrace, :c <option number> to proceed,  or :? for  
other options

CL-USER 1 : 1 > :b
Call to ERROR
Call to FLI::TYPE-CELL-GET-E-TYPE-INFO
Call to FLI::GET-FOREIGN-STRUCTURE-DESCRIPTOR
Call to FLI::FOREIGN-SLOT-VALUE-NO-KEYWORDS
Call to FLI::BASIC-FOREIGN-SLOT-VALUE
Call to OBJC::MAKE-OBJC-CLASS-IVARS
Call to OBJC::MAKE-OBJC-CLASS
Call to OBJC::INIT-OBJC-CLASS
Call to (SUBFUNCTION (LABELS OBJC::CHECK-INIT-OBJC-CLASS) OBJC::INIT- 
ALL-OBJC-CLASSES)
Call to (SUBFUNCTION (LABELS OBJC::CHECK-INIT-OBJC-CLASS) OBJC::INIT- 
ALL-OBJC-CLASSES)
Call to OBJC::INIT-ALL-OBJC-CLASSES
Call to OBJC:ENSURE-OBJC-INITIALIZED
Call to COCOA-APPLICATION:START-APPLICATION
Call to DELIVERY::MAYBE-RYB-TOP-LEVEL

CL-USER 2 : 1 >



The only code which I'm loading into LispWorks is:

cocoa-application.lisp
==============================
;;; -*- Mode: Lisp; -*-

(defpackage :cocoa-application
   (:use :common-lisp)
   (:export
    #:*frameworks-to-initialize*
    #:start-application))

(in-package :cocoa-application)

(defparameter *frameworks-to-initialize*
   '("/System/Library/Frameworks/Foundation.framework/Foundation"
     "/System/Library/Frameworks/Cocoa.framework/Cocoa"))

(defun start-application ()
   ;; initialize objc runtime
   (objc:ensure-objc-initialized :modules *frameworks-to-initialize*))
===============================


Then in order to deliver the application I'm using the following  
script and command:

deliver.lisp
========================
(in-package "CL-USER")

(load-all-patches)
(load (sys:example-file "configuration/macos-application-bundle.lisp"))

(compile-file "cocoa-application.lisp")
(load "cocoa-application")

(deliver 'cocoa-application:start-application
      (write-macos-application-bundle
       "~/Test"
       :template-bundle "/Applications/LispWorks 4.4.5/Library/lib/ 
4-4-0-0/examples/delivery/macos/templates/FullApplication.app/")
      0
      :interface nil
      :multiprocessing nil)
==========================

% /Applications/LispWorks 4.4.5/LispWorks.app/Contents/MacOS/ 
lispworks-4-4-5-darwin -siteinit - -init deliver.lisp

My expectation was that the resulting app would simply start up and  
then exit cleanly. Does anyone know what additional initialization  
LispWorks does normally? Any ideas on why objc:ensure-objc- 
initialized is dying?

Any help would be much appreciated.

Thanks,

-greg

_______________________________________________________
Greg Wuller                             greg@wuller.com
_______________________________________________________




Re: LWM: ENSURE-OBJC-INITIALIZED causes SEGV / Creating a pure Cocoa app

On Jun 14, 2005, at 3:41 PM, Greg Wuller wrote:

> So far all my attempts have resulted in an app which dies while  
> calling (objc:ensure-objc-initialized ...)

I don't know if it will help, but try adding :darwin-lw-objc to your  
modules list:

(objc:ensure-objc-initialized
      :modules  
'("/System/Library/Frameworks/Foundation.framework/Versions/C/ 
Foundation"
                  
"/System/Library/Frameworks/Cocoa.framework/Versions/A/Cocoa"
                 :darwin-lw-objc))



John DeSoi, Ph.D.
http://pgedit.com/
Power Tools for PostgreSQL


Re: LWM: ENSURE-OBJC-INITIALIZED causes SEGV / Creating a pure Cocoa app


On Jun 14, 2005, at Tue, Jun 14, 3:41 08 PM, Greg Wuller wrote:

I'm trying to create a "pure" Cocoa app (i.e. one which uses NSApplication and its event loop) with LWM 4.4.5 on Mac OS X 10.4.1. Has anyone out there tried something like this with success?


I got this to work under 4.4 but it dies exactly as you say under 4.4.5. I've since switched my approach to simply bypassing CAPI in the IDE by always loading .nib files and using objc:invoke and performSelectorOnMainThread:withObject:waitUntilDone for any cocoa calls that mess directly with the GUI.

regards,

Ralph

Raffael Cavallaro, Ph.D.
raffaelcavallaro@mac.com

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