From: Tim B. <tim...@gm...> - 2007-12-03 00:20:34
|
Hi Tim, Your post reminded me of a problem that I recently had while working with Nu. So I ported your example to Nu and saw the same message. I think the problem is in the PSMTabBarControl framework. If you look at PSMTabBarControl.m, you'll see this method: - (void)tabViewDidChangeNumberOfTabViewItems:(NSTabView *)aTabView { NSArray *tabItems = [tabView tabViewItems]; // go through cells, remove any whose representedObjects are not in [tabView tabViewItems] NSEnumerator *e = [_cells objectEnumerator]; PSMTabBarCell *cell; while(cell = [e nextObject]){ if(![tabItems containsObject:[cell representedObject]]){ [self removeTabForCell:cell]; } } ... This method is, in fact, mutating the _cells collection while it is enumerating it. I've heard that Leopard treats this more strictly, so that might explain the exception. I modified this method, replacing the call that creates the object enumerator with this: NSEnumerator *e = [[[_cells copy] autorelease] objectEnumerator]; After rebuilding and reinstalling the framework, my example worked correctly. The Nu version of your example is here: http://programming.nu/files/NuPSMTabDemo.tgz . -- Tim p.s. All the code that I wrote was in one file, as follows. It should be easy to see the correspondence back to RubyCocoa. ;; main.nu ;; Copyright (c) 2007 Tim Burks, Neon Design Technology, Inc. (load "PSMTabBarControl") (load "Nu:nu") ;; basics (load "Nu:cocoa") ;; cocoa definitions (class TabController is NSObject (ivar (id) tab_bar (id) tab_view) (- awakeFromNib is (self add_new_tab:self) (@tab_bar setStyleNamed:"Aqua") (@tab_bar setHideForSingleTab:NO) (@tab_bar setAllowsDragBetweenWindows:NO)) (- add_new_tab:sender is (set new_item ((NSTabViewItem alloc) init)) (new_item setLabel:"Badger") (@tab_view addTabViewItem:new_item) (@tab_view selectTabViewItem:new_item)) (- close_tab:sender is (@tab_view removeTabViewItem:(@tab_view selectedTabViewItem)))) ;; this makes the application window take focus when we've started it from the terminal ((NSApplication sharedApplication) activateIgnoringOtherApps:YES) ;; run the main Cocoa event loop (NSApplicationMain 0 nil) On Dec 2, 2007, at 2:01 PM, Tim Perrett wrote: > Hey all, > > I've implemented PSMTabBarControl ( http://www.positivespinmedia.com/dev/PSMTabBarControl.html > ) in my application, however I seem to get random failures > complaining like so: > > `NSApplicationMain': NSGenericException - *** Collection <NSCFArray: > 0x5598d0> was mutated while being enumerated. (OSX::OCException) > from /Users/timperrett/Desktop/RubyPSMTabDemo/build/Release/ > RubyPSMTabDemo.app/Contents/Resources/rb_main.rb:22 > > Now, I only see this message (and subsequent crash) when I try to > close a tab that is not currently selected. This however does not > happen in the example that is coded in Obj-C (supplied in that > download from PSM). Ive translated all the relevant code; the main > difference being there example is document based and my translation is > not. The framework obviously works (see the PSM example), but yet the > translation does not. > > Nib wise, I have tried with the PSM delegate both specified, and un- > specified, but it makes no difference. This leads me to think that it > must be trying to either do something back across the bridge thats > illegal, or there might be some kind of conflict with RC? > > Ive posted up a sample app here (and commented out any translated > functionality that isnt essential): http://download.timperrett.com/software/RubyPSMTabDemo.zip > > Anybody's thoughts would be much appreciated :) > > Cheers > > Tim > > > > ------------------------------------------------------------------------- > SF.Net email is sponsored by: The Future of Linux Business White Paper > from Novell. From the desktop to the data center, Linux is going > mainstream. Let it simplify your IT future. > http://altfarm.mediaplex.com/ad/ck/8857-50307-18918-4 > _______________________________________________ > Rubycocoa-talk mailing list > Rub...@li... > https://lists.sourceforge.net/lists/listinfo/rubycocoa-talk |