• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: NSOutlineView: expanding an item retains it?
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSOutlineView: expanding an item retains it?


  • Subject: Re: NSOutlineView: expanding an item retains it?
  • From: Charlton Wilbur <email@hidden>
  • Date: Mon, 24 Jan 2005 08:20:33 -0500


On Jan 24, 2005, at 7:44 AM, j o a r wrote:

Imagine a multithreaded situation. Thread 1 handles the model, perhaps interacting with other computers. Thread 2 responds to user actions. It's entirely possible for Thread 1 to release an object, then for Thread 2 to do something with the outline View -- perhaps expanding the object that was just released -- then for Thread 1 to send the reloadData message.

What does it gain you if the outline view retains the items provided to it? You don't crash in that situation, or in similar ones where reloadData might not be called immediately.

You have to be kidding? Is that how you usually ensure thread "safety"? :-D

No, I'm not kidding. It's a belt-and-suspenders approach. What it eliminates is difficult-to-track down bugs.


I imagine it's a better use of Apple engineers' time to match retains and releases in NSOutlineView than it is to handle all the bug reports filed in error because they chose to make their design aesthetically pure rather than resilient.

What does it cost you? Provided that both the outline view and your code are retain/release balanced, very little. I would expect that the NSOutlineView would release all items provided to it upon receipt of a reloadData message, for that matter; the point is to ensure that the objects do not vanish out from underneath it, to allow for graceful event handling in the event of a programmer not calling reloadData in a timely manner after releasing an object.

If you crash because the controller doesn't call reloadData when it should, then that's a bug in the controller, and not something for the data source or outline view to be concerned with.

Yes, and it can be a very difficult to track down bug, and thus while it might not be something for the outline view to be concerned with, it *is* something for the authors of the outline view code to be concerned with.


Not long ago I spent over two weeks tracking down *one* bug, which in the end turned out to be a release applied too early.

What does it gain you if NSOutlineView retains objects handed to it? It eliminates a class of bugs that would otherwise be difficult to track down and in all likelihood blamed on Apple, and turns them into obvious and easy-to-track down bugs. What does it cost you? Very little. That seems to me to be a worthwhile tradeoff.

Charlton


-- Charlton Wilbur email@hidden email@hidden

_______________________________________________
Do not post admin requests to the list. They will be ignored.
Cocoa-dev mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


References: 
 >NSOutlineView: expanding an item retains it? (From: Steve Mykytyn <email@hidden>)
 >Re: NSOutlineView: expanding an item retains it? (From: j o a r <email@hidden>)
 >Re: NSOutlineView: expanding an item retains it? (From: daniel <email@hidden>)
 >Re: NSOutlineView: expanding an item retains it? (From: Steven Kramer <email@hidden>)
 >Re: NSOutlineView: expanding an item retains it? (From: Charlton Wilbur <email@hidden>)
 >Re: NSOutlineView: expanding an item retains it? (From: j o a r <email@hidden>)
 >Re: NSOutlineView: expanding an item retains it? (From: Charlton Wilbur <email@hidden>)
 >Re: NSOutlineView: expanding an item retains it? (From: j o a r <email@hidden>)

  • Prev by Date: Re: Multiple Windows for an App question
  • Next by Date: Looking like an OS bug (Was NSAppleEventManager stops recieving events)
  • Previous by thread: Re: NSOutlineView: expanding an item retains it?
  • Next by thread: Re: NSOutlineView: expanding an item retains it?
  • Index(es):
    • Date
    • Thread