[RubyCocoa] thread and writting to UI

U

Une bévue

i've an app which uses threads.

if, within a thread, i write to a TextField by :


writeErrorMessage("Attente utilisateur")

with writeErrorMessage being :

def writeErrorMessage(msg)
@errorTextField.setStringValue(msg)
@errorTextField.oc_display
end

it's ok no prob.

however when writting :

writeErrorMessage(@prefs.servers.errorMessage)

i get error in GDB (unreadable for me) and the appli (from "Force to
quit" doesn't respond any more)

here is how the threads are organized :

Thread.new {
...
Thread.new {@prefs.servers.readNewsServers} #
update @prefs.servers.errorMessage depending on server answer
...
writeErrorMessage(@prefs.servers.errorMessage) => app hanging
...
}

and, if i replace "writeErrorMessage(@prefs.servers.errorMessage)" by a
console print-out :

p @prefs.servers.errorMessage

no error arrose ???


i've tried using mutex and doing "mutex.synchronize" around any change
and/or use of "@prefs.servers.errorMessage" but without a better working
way.


some ligth upon that ?
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,596
Members
45,135
Latest member
VeronaShap
Top