Distributed Objects & independentQueueing woes
Distributed Objects & independentQueueing woes
- Subject: Distributed Objects & independentQueueing woes
- From: Adam Iser <email@hidden>
- Date: Wed, 19 Dec 2001 22:55:29 -0500
Hi all, I'm having an annoying problem with distributed objects.
(please help :)
// Background -------------------------------------------
My program has 2 threads:
comThread - handles communication with a remote server
mainThread - handles everything else.
When a message comes in from the remote server, the comThread calls a
function in the mainThread (using distributed objects). Pretty simple :)
// Problem -------------------------------------------
My problem is that certain functions (such as [NSFont size]) send their
own DO's, returning to the run loop and allowing messages from my
comThread to get in while I'm in the middle of doing other stuff!
I was able to end almost all of my problems by calling
setIndependentConversationQueueing:YES on mainThread's NSConnection.
But I'm still having one nasty crash:
// The nasty crash -------------------------------------------
While in my custom NSCell's 'drawInteriorWithFrame:' code, I need to get
the size of a string, and call [NSString size]... size goes through a
bunch of sub functions and ends up calling the NSRuleBook
'glyphGeneratorForEncoding' method using DO's. BUT, while waiting for a
response, it allows messages from my comThread to execute code in my
mainThread (keep in mind i was in the middle of drawing a cell!). So my
'connected:' code gets called, adds a name to the outline view, redraws
some stuff, and resizes the window to make the new content visible...
*BAM* crash:
"NSInternalInconsistencyException"
-[NSLayoutManager _fillLayoutHoleAtIndex:desiredNumberOfLines:] ***
attempted layout while textStorage is editing. It is not valid to cause
the layoutManager to do layout while the textStorage is editing (ie the
textStorage has been sent a beginEditing message without a matching
endEditing.)
// Question -------------------------------------------
So how do I go about fixing this?
Is there a way to tell my comThread NOT to send any messages while I'm
in the middle of drawing my outline view cell? ... and what about other
places where things may be interrupted and cause havock that I haven't
run accross in my own testing? Or what about a way to tell the size
function NOT to let other methods get called while it's working!?
I've tried a lot of different things (such as
setIndependentConversationQueueing: both thread's connections), and
searched all over - but haven't found anything helpful yet. The Docs
say:
If your application returns to the run loop or uses distributed objects
either directly or indirectly, it can receive a remote message while it
is already busy processing another.
Which is _exactly_ what's happening to me, but the solution
(setIndependentConversationQueueing:YES) doesn't seem to help in this
instance ?:\
If you need more info I'd be glad to provide it & Thanks very much for
any help - I'm new to this distributed object stuff, so bear with me :)
-Adam Iser
http://www.adiumx.com