• 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: Attributed Strings in Distributed Objects
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Attributed Strings in Distributed Objects


  • Subject: Re: Attributed Strings in Distributed Objects
  • From: Alastair Houghton <email@hidden>
  • Date: Wed, 5 Sep 2007 12:05:00 +0100


On 5 Sep 2007, at 08:23, Gerriet M. Denkmann wrote:

I have an object, which responds to this message:

- (NSAttributedString *)dummyWithStyle: (BOOL)withStyle ;
{
NSString *s = withStyle ? @"with Style" : @"without Style";
NSMutableAttributedString *a = [ [ [ NSMutableAttributedString alloc ] initWithString: s ] autorelease ];
if ( withStyle )
{
NSParagraphStyle *p = [ NSParagraphStyle defaultParagraphStyle ];
unsigned int length = [ a length];
NSRange all = NSMakeRange( 0, length );
[ a addAttribute: NSParagraphStyleAttributeName value: p range: all ];
};

NSLog(@"%s will return %@", __FUNCTION__, a );
return a;
}


If the flag "withStyle" is NO, or if sender and reveiver live in the same thread (i.e. [myObject isProxy ] = 0) then all is fine.

But when I do: [proxyForMyObject dummyWithStyle: YES ] (with [proxyForMyObject isProxy] = 1) then the program will hang after writing the log message immediately before the return.

I think (though I could be wrong) that some object is being proxied in the main thread (possibly the attributed string itself, though I would have thought that these were always copied... it could be something to do with the attribute structure, or maybe your NSParagraphStyle that's causing the problem).


Anyway, as a result, your thread needs to run a run loop in order to process messages from the main thread. I'm guessing that your thread has terminated or is doing something other than running a run loop.

One possible way around this would be to subclass e.g. NSParagraphStyle (or whatever is causing the problem) and override - replacementObjectForPortCoder: to return self (assuming that it doesn't already). As I say, I think NSAttributedStrings are copied rather than proxied, and your backtrace seems to support that, so I don't think it's the string itself that's the issue (and if it was, you could just use "bycopy" in a declaration somewhere).

If you get your code to crash again in the same way, then do

  frame 4

and look at the invocation (depending on where you are in - sendInvocation:, and which processor architecture you're on, it could be on the stack or in a register... with luck, GDB will tell you what the argument was when you change frame, but it doesn't always get it right so you might need to step through code), you should be able to work out which object it is that's causing you grief.

Or, you could run a run loop in your other thread.

Kind regards,

Alastair.

--
http://alastairs-place.net


_______________________________________________

Cocoa-dev mailing list (email@hidden)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden


  • Follow-Ups:
    • Re: Attributed Strings in Distributed Objects
      • From: "Gerriet M. Denkmann" <email@hidden>
References: 
 >Attributed Strings in Distributed Objects (From: "Gerriet M. Denkmann" <email@hidden>)

  • Prev by Date: Using an empty string as the default value for a Core Data attribute in the XCode modeller
  • Next by Date: Re: Using an empty string as the default value for a Core Data attribute in the XCode modeller
  • Previous by thread: Attributed Strings in Distributed Objects
  • Next by thread: Re: Attributed Strings in Distributed Objects
  • Index(es):
    • Date
    • Thread