Welcome to the MacNN Forums.

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

You are here: MacNN Forums > Software - Troubleshooting and Discussion > Developer Center > Thread & NSTextField redraw problems

Thread & NSTextField redraw problems
Thread Tools
Junior Member
Join Date: Nov 2001
Location: Indiana
Status: Offline
Reply With Quote
Jan 22, 2002, 08:00 AM
 
Okay, I've got an NSThread batch processing some stuff...
It is displayed nicely inside of a sheet attached to the main window. Everything works nicely, except sometimes (randomly) when I update the NSTextView with different text, it doesn't erase the previous text. It draw right on top of it, resulting in unreadable text.

Is there some trick to alleviating this problem? It doesn't make any sense to me.
     
Senior User
Join Date: Jan 2000
Status: Offline
Reply With Quote
Jan 22, 2002, 11:49 AM
 
What calls are you using to the NSTextView? Are you clearing the field first before writing to it?

I generally do something like:

<BLOCKQUOTE><font size="1"face="Geneva, Verdana, Arial">code:</font><HR><pre><font size=1 face=courier>
[ aTextView setString: <font color = orange>@""</font> ];
[ aTextView insertText: myString ];
</font>[/code]

which clears the field entirely, and then writes to it, rather than replacing one string with another.
     
Dedicated MacNNer
Join Date: Jun 2000
Location: Dundas, Ontario, Canada
Status: Offline
Reply With Quote
Jan 22, 2002, 10:13 PM
 
I don't know how NSTextViews handle threading but you might want to try using an NSLock around the code that modifies the text view. Any time you are using multiple threads you should use lock objects to protect the API-level code. This is due to the fact that much of the API (the Application Kit especially) is not thread-safe.

Try that and tell us if it fixed the problem.
Jeff.
Spectral Class
"Shedding Light on Innovation"
     
Addicted to MacNN
Join Date: Mar 2000
Location: London, UK
Status: Offline
Reply With Quote
Jan 23, 2002, 03:17 PM
 
Any code that modifies the UI should probably happen from the main thread. See the TrivialThreads example on ADC Sample Code.
     
   
Thread Tools
Forum Links
Forum Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On
Top
Privacy Policy
All times are GMT -5. The time now is 09:46 PM.
All contents of these forums © 1995-2011 MacNN. All rights reserved.
Branding + Design: www.gesamtbild.com
vBulletin v.3.8.7 © 2000-2011, Jelsoft Enterprises Ltd., Content Relevant URLs by vBSEO 3.3.2