• 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: NSThread with Distributed Objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: NSThread with Distributed Objects


  • Subject: Re: NSThread with Distributed Objects
  • From: John Nairn <email@hidden>
  • Date: Wed, 14 Aug 2002 10:54:20 -0600

The answer was similar to your answer. It was not that the objects had been released, but that they had been created in the wrong thread and apparently pointers (or proxies to pointers in DO) will be different in the different threads. I solved it by making sure all permanent objects needed for plotting get created in the main thread that will later being plotting them. The calculation thread can then get a reference to that object and add data to it by sending messages and being careful how the data is passed in the message.

The multithreading is now working but now memory leaking is a problem. I posted a separate question on this problem earlier today.

On Wednesday, August 14, 2002, at 10:03 AM, Mike Laster wrote:

On 8/13/02 5:04 PM, "John Nairn" <email@hidden> wrote:

I have a program that I am trying to convert to multiple threading but I
am stopped by a confusing error. This program uses distributed objects
with a calculation thread to create plotting objects and a main thread
where all interface commands are done. As far as I know, the
calculation thread never calls the AppKit. All seems to work OK, but
when the calculation thread is over and the main thread is drawing the
objects, the following error appears:

2002-08-13 14:55:14.860 ScienceCocoa[2928] *** -[NSCalibratedRGBColor
viewBounds]: selector not recognized

This occurs when the drawing code is calling a class that was created in
the main thread and filled with data in the calculation thread. The
class is called "PlotHeader" and its single instance variable is
"plotObjects". This error seems to come when the main thread tries the
mssage

[plotObjects viewBounds]

and Objective C seems to now think plotObjects has become an
NSCalibratedRGBColor instead of what is was before. The error is usually
of this form, but sometimes other errors occurs which I expect are also
because Objective C somehow no longer knows that plotObjects is pointing
to a PlotHeader object.

Does this error make sense or any ideas what causes it?

P.S.: The code works fine when non threaded.

It sounds like your object is getting dealloced and then you attempt to
access it later. Try running with the following environment variables set:

NSZombieEnabled = YES
NSAutoreleaseFreedObjectCheckEnabled = YES

You should see the code complaining if you attempt to access a dealloced
object.


----------------
John Nairn (1-801-581-3413, FAX: 1-801-581-4816)
Web page: http://www.mse.utah.edu/~nairn
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

References: 
 >Re: NSThread with Distributed Objects (From: Mike Laster <email@hidden>)

  • Prev by Date: Re: How do I inhibi the I beam cursor in a NSTextView
  • Next by Date: Re: NSTask and avoiding buffered standard out
  • Previous by thread: Re: NSThread with Distributed Objects
  • Next by thread: Stupid newbie question — determine if intege r is even or odd
  • Index(es):
    • Date
    • Thread