Re: Opening a background window in a separate thread



On Sun, 2008-11-30 at 09:11 +0000, Rob Pearce wrote:
> but you must always keep ALL the GTK calls (with one or two 
> useful exceptions) in the same thread.

That is not correct.

All GTK calls must be made holding the GDK lock, which you get by
surrounding *all* GTK calls with:

        gdk_threads_enter();

and

        gdk_threads_leave();

most people do not notice this because having surrounded the call to
gtk_main() with these, all your signal handler callbacks are within [are
already holding] the main lock.

But if you call code from anywhere else (ie, another thread, or an idle
callback), then you must protect your calls with these functions.

++

GTK's thread safety does not work on Microsoft's proprietary OS.

[There was once-upon-a-time some interesting discussion about ways to
change GTK's win32 backend to engineer around this, but until that day
the workaround for people developing on win32 has long been "only make
GTK calls from one thread" which is a shame, but one place confusion
stems from]

AfC
Sydney

-- 
Andrew Frederick Cowie

Operational Dynamics is an operations and engineering consultancy
focusing on IT strategy, organizational architecture, systems
review, and effective procedures for change management: enabling
successful deployment of mission critical information technology in
enterprises, worldwide.

http://www.operationaldynamics.com/

Sydney   New York   Toronto   London

Attachment: signature.asc
Description: This is a digitally signed message part



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