refreshing widgets from callback



Hi,

I had a function to refresh some widgets. Inside this function I perfomed a
gdk_threads_enter() / gdk_threads_leave() to prevent access from the
secondary thread.

update()
{
gdk_threads_enter()
...
...
gdk_threads_leave()
}

I wanted to reuse this function from a callback, but since callbacks run
inside a gdk lock I should remove my own lock to avoid a deadlock problem.
So I move the lock out of the function:

gdk_threads_enter()
update()
gdk_threads_leave()

This works fine and solves my problem. Should I assume is not a good
practice (for reusing at least) to lock gdk inside a function?
Am I confussing concepts? Is there a better way to do this?
I mean that it is possible that some code in update() could be done outside
of the lock... and if it can, it should be done outside to not locking the
other threads for a long time, right? (extrictly more time than necessary)

Best regards!



[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]