From: Sal S. <sal...@gm...> - 2008-02-13 01:44:39
|
anyone else getting KERN_ACCESS_ERRORS using threads ala NSTask since 10.5.2? require 'osx/cocoa' class CmdTask attr_accessor :task_obj, :status TASK_DONE = 1<<0 TASK_TERM = 1<<1 TASK_COMP = TASK_DONE|TASK_TERM end class CmdRunner attr_accessor :delegate, :start, :finished, :data def initialize end def run_command(cmd, args) @task = OSX::NSTask.alloc.init @pipe = OSX::NSPipe.alloc.init @pipH = @pipe.fileHandleForReading @task.setLaunchPath(cmd) @task.setStandardError(@pipe) @task.setStandardOutput(@pipe) @task.setArguments(args) center = OSX::NSNotificationCenter.defaultCenter center .addObserver_selector_name_object (self,'readPipe:',OSX::NSFileHandleReadCompletionNotification,nil) center .addObserver_selector_name_object (self,'statusPipe:',OSX::NSTaskDidTerminateNotification,nil) @pipH.readInBackgroundAndNotify @task.launch @delegate.send(@start) @taskd = CmdTask.new @taskd.task_obj = @task @taskd.status = 0 end def readPipe(ntf) inData = ntf.userInfo.objectForKey(OSX::NSFileHandleNotificationDataItem) if inData.length > 0 then ntf.object.readInBackgroundAndNotify str = OSX::NSString.alloc.initWithData_encoding(inData, OSX::NSASCIIStringEncoding) puts "R: #{str}" @delegate.send(@data, str.to_ruby) else taskDone(CmdTask::TASK_DONE) end end def statusPipe(ntf) @exit_status = ntf.object.terminationStatus taskDone(CmdTask::TASK_TERM) end def taskDone(flag) s = (@taskd.status.to_i | flag) @taskd.status = s if @taskd.status == CmdTask::TASK_COMP cleanup @delegate.send(@finished,@exit_status) end end def terminate if @task && @task.isRunning @task.terminate end end def cleanup center = OSX::NSNotificationCenter.defaultCenter center.removeObserver(self) @taskd.task_obj = nil @taskd = nil @pipe = nil end end -- That code worked in 10.5.1, not it crashes in 10.5.2 or totally hangs the app On Feb 12, 2008, at 5:49 AM, rub...@li... wrote: > Send Rubycocoa-talk mailing list submissions to > rub...@li... > > To subscribe or unsubscribe via the World Wide Web, visit > https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk > or, via email, send a message with subject or body 'help' to > rub...@li... > > You can reach the person managing the list at > rub...@li... > > When replying, please edit your Subject line so it is more specific > than "Re: Contents of Rubycocoa-talk digest..." > > > Today's Topics: > > 1. Info.plist LSEnvironment does not set ENV, > processInfo.environment (Brian Marick) > 2. Draft chapter of RubyCocoa book (Brian Marick) > 3. Re: Info.plist LSEnvironment does not set ENV, > processInfo.environment (kimura wataru) > 4. Re: Info.plist LSEnvironment does not set ENV, > processInfo.environment (Brian Marick) > 5. Re: Info.plist LSEnvironment does not set ENV, > processInfo.environment (kimura wataru) > 6. iokit support? (Axel M. Roest) > 7. iokit support? (Axel M. Roest) > 8. Re: standaloneify.rb tool (Rich Warren) > > > ---------------------------------------------------------------------- > > Message: 1 > Date: Thu, 7 Feb 2008 13:01:14 -0600 > From: Brian Marick <ma...@ex...> > Subject: [Rubycocoa-talk] Info.plist LSEnvironment does not set ENV, > processInfo.environment > To: rubycocoa rubycocoa <rub...@li...> > Message-ID: <23C...@ex...> > Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes > > Using RubyCocoa from Leopard (10.5.1) : > > You can declare environment variables in a Cocoa app's Info.plist file > like this: > > <key>LSEnvironment</key> > <dict> > <key>VEX</key> > <string>acious!</string> > </dict> > > In an Objective-C app, that value carries over into the environment: > > NSDictionary *env = [[NSProcessInfo processInfo] environment]; > NSLog(@"====Here is the value of VEX in the processInfo > environment: %@", > [env objectForKey:@"VEX"]); > > NSDictionary *lsEnv = [[NSBundle mainBundle] > objectForInfoDictionaryKey: @"LSEnvironment"]; > NSLog(@"====Here is the value of VEX from the Info.plist > environment: %@", > [lsEnv objectForKey:@"VEX"]); > > > Feb 7 12:34:56 frex Test[1660]: ====Here is the value of VEX in the > processInfo environment: acious! > Feb 7 12:34:56 frex Test[1660]: ====Here is the value of VEX from the > Info.plist environment: acious! > > > However, the value from Info.plist doesn't seem to make it into ENV. > More surprisingly, it doesn't make it into the Cocoa processInfo > environment: > > $stderr.puts "==== Here is the value of VEX in the environment:" > $stderr.puts ENV['VEX'].inspect > > $stderr.puts "==== The value of VEX in the processInfo > environment:" > cocoa_env = NSProcessInfo.processInfo.environment > $stderr.puts cocoa_env.objectForKey("VEX") > > $stderr.puts "==== The value of VEX in Info.plist:" > plist_env = > NSBundle.mainBundle.objectForInfoDictionaryKey("LSEnvironment") > $stderr.puts plist_env.objectForKey("VEX") > > Feb 7 12:49:45 frex [0x0-0xc70c7].com.exampler.StatusbarApp[1689]: > ==== Here is the value of VEX in the environment: > Feb 7 12:49:45 frex [0x0-0xc70c7].com.exampler.StatusbarApp[1689]: > nil > Feb 7 12:49:45 frex [0x0-0xc70c7].com.exampler.StatusbarApp[1689]: > ==== The value of VEX in the processInfo environment: > Feb 7 12:49:45 frex [0x0-0xc70c7].com.exampler.StatusbarApp[1689]: > nil > Feb 7 12:49:45 frex [0x0-0xc70c7].com.exampler.StatusbarApp[1689]: > ==== The value of VEX in Info.plist: > Feb 7 12:49:45 frex [0x0-0xc70c7].com.exampler.StatusbarApp[1689]: > acious! > > > ----- > Brian Marick, independent consultant > Mostly on agile methods with a testing slant > www.exampler.com, www.exampler.com/blog, www.twitter.com/marick > > > > > ------------------------------ > > Message: 2 > Date: Fri, 8 Feb 2008 15:17:00 -0600 > From: Brian Marick <ma...@ex...> > Subject: [Rubycocoa-talk] Draft chapter of RubyCocoa book > To: rubycocoa rubycocoa <rub...@li...> > Message-ID: <65C...@ex...> > Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes > > I'm writing a book on RubyCocoa for the Pragmatic Bookshelf, publisher > of many fine titles. <http://www.pragprog.com/titles> > > I'm ready for people to take a look at a chapter. It's actually the > second chapter. The preceding introduction, covering prerequisites, > the general plan of the book, its goals, what "Cocoa" is, etc. -- that > will probably be written last. > > But to orient yourselves: > > - I assume you know Ruby, but nothing about Objective-C, Cocoa, or > building apps on the Mac. > > - Rather than build the exposition from the outside-in, teaching you > first how to draw user interfaces, I'm working from Ruby up. I start > with Ruby, then begin adding Cocoa ideas and tools onto it. > > - Especially in the beginning of the book, I want people to start > changing code and seeing what happens. Might as well take advantage of > Ruby's fast edit-run loop. > > The chapter and associated code are distributed as a disk image: http://www.exampler.com/tmp/drafts/draft-of-2008-02-08.dmg > > What am I looking for? Don't bother with typos, misspellings, grammar, > awkwardly-placed figures, and the like: those will all get changed > later. I'm interested in two things: > > 1. Did the approach work for you? Did this chapter flow in a pleasing > and sensible way? Is there information inexplicably missing? > > 2. Where did you get confused or stuck, in either the text or the "try > this yourself" sections? Why? What would have helped? > > Thanks. > > Further announcements will go only to the mailing list: > http://groups.google.com/group/rubycocoa-book > > ----- > Brian Marick, independent consultant > Mostly on agile methods with a testing slant > www.exampler.com, www.exampler.com/blog, www.twitter.com/marick > > > > > ------------------------------ > > Message: 3 > Date: Sat, 9 Feb 2008 09:56:20 +0900 > From: kimura wataru <ki...@us...> > Subject: Re: [Rubycocoa-talk] Info.plist LSEnvironment does not set > ENV, processInfo.environment > To: rub...@li... > Message-ID: <200...@us...> > Content-Type: text/plain; charset=us-ascii > > Hi, > > It works for me on 10.5.1. > LSEnvironment is available for apps launched via Launch Service. > - double-click in Finder > - launch with "open" command > > LSEnvironment is not available without Launch Service. > - "Run" on Xcode > - execute YourApp.app/Contents/MacOS/YourApp directly > > > On Thu, 7 Feb 2008 13:01:14 -0600, Brian Marick wrote: >> Using RubyCocoa from Leopard (10.5.1) : >> >> You can declare environment variables in a Cocoa app's Info.plist >> file >> like this: >> >> <key>LSEnvironment</key> >> <dict> >> <key>VEX</key> >> <string>acious!</string> >> </dict> >> >> In an Objective-C app, that value carries over into the environment: >> >> NSDictionary *env = [[NSProcessInfo processInfo] environment]; >> NSLog(@"====Here is the value of VEX in the processInfo >> environment: %@", >> [env objectForKey:@"VEX"]); > -- > kimura wataru > > > > ------------------------------ > > Message: 4 > Date: Sat, 9 Feb 2008 12:56:41 -0600 > From: Brian Marick <ma...@ex...> > Subject: Re: [Rubycocoa-talk] Info.plist LSEnvironment does not set > ENV, processInfo.environment > To: rub...@li... > Message-ID: <4AE...@ex...> > Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes > > > On Feb 8, 2008, at 6:56 PM, kimura wataru wrote: > >> Hi, >> >> It works for me on 10.5.1. >> > > Can you send me the App bundle you used? I want to see what I'm doing > differently. > > > > ----- > Brian Marick, independent consultant > Mostly on agile methods with a testing slant > www.exampler.com, www.exampler.com/blog, www.twitter.com/marick > > > > > ------------------------------ > > Message: 5 > Date: Sun, 10 Feb 2008 11:57:33 +0900 > From: kimura wataru <ki...@us...> > Subject: Re: [Rubycocoa-talk] Info.plist LSEnvironment does not set > ENV, processInfo.environment > To: rub...@li... > Message-ID: <200...@us...> > Content-Type: text/plain; charset=us-ascii > > Hi Brian, > > I uploaded an archive of the Xcode project I tested > onto the following URL. > > http://kirika.la.coocan.jp/archive/misc/LSEnv.zip > > On Sat, 9 Feb 2008 12:56:41 -0600, Brian Marick wrote: >> >> On Feb 8, 2008, at 6:56 PM, kimura wataru wrote: >> >>> Hi, >>> >>> It works for me on 10.5.1. >>> >> >> Can you send me the App bundle you used? I want to see what I'm doing >> differently. >> > -- > kimura wataru > > > > ------------------------------ > > Message: 6 > Date: Mon, 11 Feb 2008 13:14:12 +0100 > From: "Axel M. Roest" <ax...@ro...> > Subject: [Rubycocoa-talk] iokit support? > To: rub...@li... > Message-ID: <p06240804c3d5e8241bc5@[192.168.8.100]> > Content-Type: text/plain; charset="us-ascii" ; format="flowed" > > Hi, > I want to incorporate Obj-C classes from AMSerialPort > <http://www.harmless.de/cocoa.php> in my RubyCocoa project. The > problem is that these refer to IOkit classes, and use CoreFoundation > char* string constants (kIOSerialBSDModemType), which are not > available in Ruby. > > The reference in Obj-C is: > #import <IOKit/serial/IOSerialKeys.h> > // note: the constants are C strings, so use '@' or CFSTR to convert, > for example: > // NSArray *ports = [[AMSerialPort sharedPortList] > serialPortsOfType:@kIOSerialBSDModemType]; > // NSArray *ports = [[AMSerialPort sharedPortList] > serialPortsOfType:(NSString*)CFSTR(kIOSerialBSDModemType)]; > > How do I do this in RubyCocoa? > I can try to hack around these for now, but I would prefer a more > portable solution. > > Is it possible to easily add IOKit or CoreFoundation support to > RubyCocoa? > Or is it better to make an Obj-C bridge class in my project that > interfaces with the AMSerialPort class? > > Oh, and I tried to use the really old ruby SerialPort > <http://ruby-serialport.rubyforge.org/> implementation, but > multi-threading that to get serial input does not seem to work as > well as the AMSerialPort class. > > Thanks > > Axel > -- > _________________________ > Axel Roest > axelloroestello@{AIM/MSN} - Skype:axellofono - XOIP: 084-8749988 > > > > ------------------------------ > > Message: 7 > Date: Mon, 11 Feb 2008 16:49:00 +0100 > From: "Axel M. Roest" <rub...@ro...> > Subject: [Rubycocoa-talk] iokit support? > To: rub...@li... > Message-ID: <p06240800c3d61ed9a0f7@[172.16.42.206]> > Content-Type: text/plain; charset="us-ascii" ; format="flowed" > > Hi, > I want to incorporate Obj-C classes from AMSerialPort > <http://www.harmless.de/cocoa.php> in my RubyCocoa project. The > problem is that these refer to IOkit classes, and use CoreFoundation > char* string constants (kIOSerialBSDModemType), which are not > available in Ruby. > > The reference in Obj-C is: > #import <IOKit/serial/IOSerialKeys.h> > // note: the constants are C strings, so use '@' or CFSTR to convert, > for example: > // NSArray *ports = [[AMSerialPort sharedPortList] > serialPortsOfType:@kIOSerialBSDModemType]; > // NSArray *ports = [[AMSerialPort sharedPortList] > serialPortsOfType:(NSString*)CFSTR(kIOSerialBSDModemType)]; > > How do I do this in RubyCocoa? > I can try to hack around these for now, but I would prefer a more > portable solution. > > Is it possible to easily add IOKit or CoreFoundation support to > RubyCocoa? > Or is it better to make an Obj-C bridge class in my project that > interfaces with the AMSerialPort class? > > Oh, and I tried to use the really old ruby SerialPort > <http://ruby-serialport.rubyforge.org/> implementation, but > multi-threading that to get serial input does not seem to work as > well as the AMSerialPort class. > > Thanks > > Axel > -- > _________________________ > Axel Roest > axelloroestello@{AIM/MSN} - Skype:axellofono - XOIP: 084-8749988 > > > > ------------------------------ > > Message: 8 > Date: Tue, 12 Feb 2008 00:49:18 -1000 > From: Rich Warren <rw...@gm...> > Subject: Re: [Rubycocoa-talk] standaloneify.rb tool > To: rub...@li... > Message-ID: <665...@gm...> > Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes > > Ok, I'm giving up (at least temporarily). > > Standaloneify just doens't seem to play well with Leopard. > > I edited rb_main.rb to add the RubyCocoa and all the main Ruby > libraries back into the $LOAD_PATH. This let me run the application on > my development machine. However, when I tried to move it to another > computer, it refused to run. > > I spend a lot of time playing with the load paths, but kept getting > odd errors, and never got it to work right. It always complained about > an uninitialized constant OSX::NSString::NKF. Nothing I tried could > get around this. > > So I had XCode copy the RubyCocoa bundle into the application--but > that wouldn't even run locally (I probably have to add the Ruby > libraries back into the path again...or maybe copy the Ruby framework > into the app...but that's starting to get ridiculous). > > It doesn't really matter for this project. But, it would be nice to > have some way of bundling the gems I'm using into the app itself. > > Any suggestions? > > -Rich- > > On Feb 4, 2008, at 2:44 AM, Eloy Duran wrote: > >> After you've added the copy files build phase, >> you'll need to drag RubyCocoa.framework into that "copy files build >> phase" too. >> >> However, if your app works with the default Leopard RubyCococa >> and you're only targeting Leopard, then I would not bundle it >> but rather fix your load path problem. >> >> So if you look at the rb_,main.rb file of your standaloneified >> bundle, >> at the top you'll see some code that was added by Standaloneify. >> Underneath that do something like: >> $LOAD_PATH.unshift("/Library/Ruby/Site/1.8") >> >> Then you should probably be able to do: require 'osx/cocoa' >> >> Cheers, >> Eloy >> >> On 4 feb 2008, at 10:28, Rich Warren wrote: >> >>> Ok, I tried to bundle the RubyCocoa framework, but Xcode won't seem >>> to >>> let me. >>> >>> I added a new copy files build phase. >>> I set the destination to "Frameworks". >>> I then added an existing framework, and selected RubyCocoa >>> >>> The "Add" button is highlighted. But pressing it doesn't seem to do >>> anything. >>> >>> Clearly I'm doing something wrong here. How do I bundle RubyCocoa >>> into >>> my app? >>> >>> -Rich- >>> >>> On Feb 3, 2008, at 10:54 PM, Eloy Duran wrote: >>> >>>> Hi Rich, >>>> >>>> It's true that andy Leopard install will have RubyCocoa installed. >>>> However iirc standaloneify will completely empty your load path >>>> before starting the application. >>>> This means that unless you've bundled the framework it won't be >>>> found. >>>> So my guess is that you haven't bundled the framework inside your >>>> app, >>>> which is ok of course, but in wich case you'll have to edit your >>>> rb_main.rb >>>> file after it has been standalonified to setup the correct load >>>> path >>>> or maybe >>>> even better; instead of doing "require 'osx/cocoa'" try to specify >>>> the >>>> full path. >>>> >>>> Cheers, >>>> Eloy >>>> >>>> On 4 feb 2008, at 02:12, Rich Warren wrote: >>>> >>>>> Hi, >>>>> >>>>> I'm trying to embed some RubyGem libraries into a stand alone app. >>>>> According to the web site, I used the following command: >>>>> >>>>> ruby standaloneify.rb -d RubyRSS_StandAlone.app RubyRSS.app >>>>> >>>>> Everything seemed fine. But when I tried to run the stand alone >>>>> app, >>>>> It fails to launch. I get the following message in the console: >>>>> >>>>> 2/3/08 3:03:57 PM >>>>> [0x0 >>>>> -0x31031].com.apple.rubycocoa.NEWCOREDATAPROJECT.RubyRSSApp[278] / >>>>> Users/rikiwarren/Desktop/RubyRSS_StandAlone.app/Contents/ >>>>> Resources/ >>>>> rb_main.rb:25:in `require': no such file to load -- osx/cocoa >>>>> (LoadError) >>>>> >>>>> 2/3/08 3:03:57 PM >>>>> [0x0 >>>>> -0x31031].com.apple.rubycocoa.NEWCOREDATAPROJECT.RubyRSSApp[278] >>>>> from /Users/rikiwarren/Desktop/RubyRSS_StandAlone.app/Contents/ >>>>> Resources/rb_main.rb:25 >>>>> >>>>> 2/3/08 3:03:57 PM com.apple.launchd[63] >>>>> ([0x0 >>>>> -0x31031].com.apple.rubycocoa.NEWCOREDATAPROJECT.RubyRSSApp[278]) >>>>> Exited with exit code: 1 >>>>> >>>>> If I'm reading this right, it's having trouble finding the osx/ >>>>> cocoa >>>>> library. However, since I'm working on Leopard, all Leopard >>>>> machines >>>>> should have osx/cocoa installed by default, right? >>>>> >>>>> Am I doing something wrong? How do I get standaloneify to work on >>>>> Leopard? >>>>> >>>>> Thanks, >>>>> >>>>> -Rich- >>>>> >>>>> ------------------------------------------------------------------------- >>>>> This SF.net email is sponsored by: Microsoft >>>>> Defy all challenges. Microsoft(R) Visual Studio 2008. >>>>> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ >>>>> _______________________________________________ >>>>> Rubycocoa-talk mailing list >>>>> Rub...@li... >>>>> https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk >>>> >>>> >>>> ------------------------------------------------------------------------- >>>> This SF.net email is sponsored by: Microsoft >>>> Defy all challenges. Microsoft(R) Visual Studio 2008. >>>> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ >>>> _______________________________________________ >>>> Rubycocoa-talk mailing list >>>> Rub...@li... >>>> https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk >>> >>> >>> ------------------------------------------------------------------------- >>> This SF.net email is sponsored by: Microsoft >>> Defy all challenges. Microsoft(R) Visual Studio 2008. >>> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ >>> _______________________________________________ >>> Rubycocoa-talk mailing list >>> Rub...@li... >>> https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk >> >> >> ------------------------------------------------------------------------- >> This SF.net email is sponsored by: Microsoft >> Defy all challenges. Microsoft(R) Visual Studio 2008. >> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ >> _______________________________________________ >> Rubycocoa-talk mailing list >> Rub...@li... >> https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk > > > > > ------------------------------ > > ------------------------------------------------------------------------- > This SF.net email is sponsored by: Microsoft > Defy all challenges. Microsoft(R) Visual Studio 2008. > http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/ > > ------------------------------ > > _______________________________________________ > Rubycocoa-talk mailing list > Rub...@li... > https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk > > > End of Rubycocoa-talk Digest, Vol 21, Issue 14 > ********************************************** |